--- Java classes from package @java.util@

protected module frege.java.Util where

import frege.java.Lang 
import frege.java.util.Regex
import frege.prelude.PreludeBase
import frege.prelude.PreludeIO
import frege.prelude.PreludeText
import frege.prelude.PreludeList
import frege.prelude.PreludeMonad
import frege.control.Semigroupoid(•)
import frege.prelude.PreludeArrays (ArrayElement, JArray)
import frege.java.IO (
  IOException, UnsupportedEncodingException, InputStream, OutputStream, PrintStream, PrintWriter, Writer)

data NoSuchElementException = pure native java.util.NoSuchElementException
derive Exceptional NoSuchElementException

data Enumeration e = native java.util.Enumeration where
        native hasMoreElements :: Mutable s (Enumeration e) -> ST s Bool
        native nextElement     :: Mutable s (Enumeration e) -> ST s e
                                    throws NoSuchElementException
        toList :: Mutable s (Enumeration e) -> ST s [e]
        toList enum = loop  []
            where
                loop acc = do
                    more <- enum.hasMoreElements
                    if more
                      then do
                        elem <- enum.nextElement
                        loop (elem:acc)
                    else return (reverse acc)

{--
    A value of this type is used to generate a stream of pseudorandom numbers.
    The type uses a 48-bit seed, which is modified using a linear congruential formula.
    (See Donald Knuth, The Art of Computer Programming, Volume 2, Section 3.2.1.)

    If two 'Random' values are created with the same seed,
    and the same sequence of method calls is made for each,
    they will generate and return identical sequences of numbers.
    In order to guarantee this property, particular algorithms are
    specified for the class Random.

    Many applications will find the function 'frege.prelude.Math#random'
    simpler to use.
-}
data Random = native java.util.Random  where
    {--
        Create a new random number generator.

        If no seed is given, a value very likely to be distinct from any other
        invocation of the constructor will be computed from the
        state of the real world.
    -}
    native new                      :: ()   -> IOMutable   Random
                                    |  Long -> STMutable s Random

    {--
        Returns the next pseudorandom, uniformly distributed
        'Bool' value from this random number generator's sequence.
    -}
    native nextBoolean              :: Mutable s Random -> ST s Bool

    {--
        Returns the next pseudorandom, uniformly distributed
        'Double' value between 0.0 and 1.0
        from this random number generator's sequence.
    -}
    native nextDouble               :: Mutable s Random -> ST s Double

    {--
        Returns the next pseudorandom, uniformly distributed
        'Float' value between 0.0 and 1.0
        from this random number generator's sequence.
    -}
    native nextFloat                :: Mutable s Random -> ST s Float

    {--
        Returns the next pseudorandom, Gaussian ("normally") distributed
        'Double' value with mean 0.0 and standard deviation 1.0 from this
        random number generator's sequence.
    -}
    native nextGaussian             :: Mutable s Random -> ST s Double

    {--
        > random.nextInt
        Returns the next pseudorandom,
        uniformly distributed 'Int'
        value from this random number generator's sequence.

        > random.nextInt limit
        Returns a pseudorandom, uniformly distributed
        'Int' value between 0 (inclusive) and the specified value (exclusive),
        drawn from this random number generator's sequence.
        The _limit_ must be positive.
    -}
    native nextInt                  :: Mutable s Random -> ST s Int
                                    |  Mutable s Random -> Int -> ST s Int

    {--
        Returns the next pseudorandom, uniformly distributed
        'Long' value from this random number generator's sequence.
    -}
    native nextLong                :: Mutable s Random -> ST s Long

    --- Sets the seed of this random number generator using a single long seed.
    native setSeed                  :: Mutable s Random -> Long -> ST s ()

{--
 An Entry maintaining an immutable key and value. This class does not support method @setValue@.
 This class may be convenient in methods that return thread-safe snapshots of key-value mappings.
-}
data AbstractMapSimpleImmutableEntry k v = pure native java.util.AbstractMap.SimpleImmutableEntry where

  {--
   Creates an entry representing a mapping from the specified key to the specified value or
   if an entry is provided, it creates an entry representing the same mapping as the specified entry.
  -}
  native new :: k -> v -> ST s (AbstractMapSimpleImmutableEntry k v)
              | Mutable s (MapEntry k v) -> ST s (AbstractMapSimpleImmutableEntry k v)

  pure native equals :: AbstractMapSimpleImmutableEntry k v -> Object -> Bool

  pure native getKey :: AbstractMapSimpleImmutableEntry k v -> k

  pure native getValue :: AbstractMapSimpleImmutableEntry k v -> v

  pure native hashCode :: AbstractMapSimpleImmutableEntry k v -> Int

  {- Removed because it always throws @UnsupportedOperationException@
   - See here for more details:
   - http://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.SimpleImmutableEntry.html#setValue(V)
   -}
  --pure native setValue :: AbstractMapSimpleImmutableEntry k v -> v -> v

  pure native toString :: AbstractMapSimpleImmutableEntry k v -> String

instance Serializable (AbstractMapSimpleImmutableEntry k v)

-- forward declarations, we don't want to import java.io here
protected data Reader = native java.io.Reader
protected data File   = pure native java.io.File
protected data FileNotFoundException = pure native java.io.FileNotFoundException

{--
   From Javadoc:
   A comparison function, which imposes a total ordering on some collection of objects.
   Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow
   precise control over the sort order. Comparators can also be used to control the order of
   certain data structures (such as sorted sets or sorted maps), or to provide
   an ordering for collections of objects that don't have a natural ordering.

   More: 'http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html Comparator JavaDoc'
-}

data Comparator t = pure native java.util.Comparator {t} where

  pure native compare :: Comparator t -> t -> t -> Int

  pure native equals :: Comparator t -> Comparator t -> Bool


{--
 This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface.
 The process of implementing a set by extending this class is identical to that of implementing a Collection
 by extending AbstractCollection, except that all of the methods and constructors in subclasses of this class
 must obey the additional constraints imposed by the Set interface (for instance, the add method must not permit
 addition of multiple instances of an object to a set).

 Note that this class does not override any of the implementations from the AbstractCollection class.
 It merely adds implementations for equals and hashCode.
-}
data AbstractSet e = native java.util.AbstractSet where

  native equals :: Mutable s (AbstractSet e) -> Object -> ST s Bool

  native hashCode :: Mutable s (AbstractSet e) -> ST s Int

  native removeAll :: Mutable s (AbstractSet e) -> Mutable s (Collection Object) -> ST s Bool

{--
 The Stack class represents a last-in-first-out (LIFO) stack of objects.
 It extends class Vector with five operations that allow a vector to be treated as a stack.
 The usual push and pop operations are provided, as well as a method to peek at the top item on the stack,
 a method to test for whether the stack is empty, and a method to search the stack for an item and
 discover how far it is from the top.

 When a stack is first created, it contains no items.

 A more complete and consistent set of LIFO stack operations is provided by the Deque interface and
 its implementations, which should be used in preference to this class. For example:

 > Deque<Integer> stack = new ArrayDeque<Integer>();

-}
data Stack e = native java.util.Stack where

  --- Creates an empty Stack.
  native new :: () -> STMutable s (Stack e)

  --- Tests if this stack is empty.
  native empty :: Mutable s (Stack e) -> ST s Bool

  --- Looks at the object at the top of this stack without removing it from the stack.
  native peek :: Mutable s (Stack e) -> ST s e

  --- Removes the object at the top of this stack and returns that object as the value of this function.
  native pop :: Mutable s (Stack e) -> ST s e

  --- Pushes an item onto the top of this stack.
  native push :: Mutable s (Stack e) -> e -> ST s e

  --- Returns the 1-based position where an object is on this stack.
  native search :: Mutable s (Stack e) -> Object -> ST s Int

instance Serializable (Stack e)

{--
 A Set that further provides a total ordering on its elements.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/SortedSet.html SortedSet JavaDoc'
-}
data SortedSet e = native java.util.SortedSet where

  --- Returns the comparator used to order the elements in this set, or null if this set uses the
  --- 'https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html natural ordering' of its elements.
  native comparator :: Mutable s (SortedSet e) -> ST s (Comparator (≥e))

  --- Returns the first (lowest) element currently in this set.
  native first :: Mutable s (SortedSet e) -> ST s e

  --- Returns a view of the portion of this set whose elements are strictly less than toElement.
  native headSet :: Mutable s (SortedSet e) -> e -> STMutable s (SortedSet e)

  --- Returns the last (highest) element currently in this set.
  native last :: Mutable s (SortedSet e) -> ST s e

  --- Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
  native subSet :: Mutable s (SortedSet e) -> e -> e -> STMutable s (SortedSet e)

  --- Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
  native tailSet :: Mutable s (SortedSet e) -> e -> STMutable s (SortedSet e)

{-

    warning: [deprecation] Observable in java.util has been deprecated

 This class represents an observable object, or "data" in the model-view paradigm.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Observable.html Observable JavaDoc'

data Observable = native java.util.Observable where
  --- Construct an Observable with zero Observers.
  native new :: () -> STMutable s Observable

  --- Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the set.
  native addObserver :: Mutable s Observable -> Mutable s Observer -> ST s ()

  --- Returns the number of observers of this Observable object.
  native countObservers :: Mutable s Observable -> ST s Int

  --- Deletes an observer from the set of observers of this object.
  native deleteObserver :: Mutable s Observable -> Mutable s Observer -> ST s ()

  --- Clears the observer list so that this object no longer has any observers.
  native deleteObservers :: Mutable s Observable -> ST s ()

  --- Tests if this object has changed.
  native hasChanged :: Mutable s Observable -> ST s Bool

  --- If this object has changed, as indicated by the hasChanged method, then notify all of its observers and
  --- then call the clearChanged method to indicate that this object has no longer changed.
  native notifyObservers :: Mutable s Observable -> Object -> ST s ()
                          | Mutable s Observable -> ST s ()
-}

{--
 A linear collection that supports element insertion and removal at both ends.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html Deque JavaDoc'
-}
data Deque e = native java.util.Deque where

  {-- Inserts the specified element into the queue represented by this deque (in other words, at the tail
   of this deque) if it is possible to do so immediately without violating capacity restrictions,
   returning true upon success and throwing an IllegalStateException if no space is currently available.
  -}
  native add :: Mutable s (Deque e) -> e -> ST s Bool

  --- Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions.
  native addFirst :: Mutable s (Deque e) -> e -> ST s ()

  --- Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions.
  native addLast :: Mutable s (Deque e) -> e -> ST s ()

  --- Returns true if this deque contains the specified element.
  native contains :: Mutable s (Deque e) -> Object -> ST s Bool

  --- Returns an iterator over the elements in this deque in reverse sequential order.
  native descendingIterator :: Mutable s (Deque e) -> STMutable s (Iterator e)

  --- Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).
  native element :: Mutable s (Deque e) -> ST s e

  --- Retrieves, but does not remove, the first element of this deque.
  native getFirst :: Mutable s (Deque e) -> ST s e

  --- Retrieves, but does not remove, the last element of this deque.
  native getLast :: Mutable s (Deque e) -> ST s e

  --- Returns an iterator over the elements in this deque in proper sequence.
  native iterator :: Mutable s (Deque e) -> STMutable s (Iterator e)

  --- Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque)
  --- if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.
  native offer :: Mutable s (Deque e) -> e -> ST s Bool

  --- Inserts the specified element at the front of this deque unless it would violate capacity restrictions.
  native offerFirst :: Mutable s (Deque e) -> e -> ST s Bool

  --- Inserts the specified element at the end of this deque unless it would violate capacity restrictions.
  native offerLast :: Mutable s (Deque e) -> e -> ST s Bool

  --- Retrieves, but does not remove, the head of the queue represented by this deque (in other words,
  --- the first element of this deque), or returns null if this deque is empty.
  native peek :: Mutable s (Deque e) -> ST s e

  --- Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
  native peekFirst :: Mutable s (Deque e) -> ST s e

  --- Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
  native peekLast :: Mutable s (Deque e) -> ST s e

  --- Retrieves and removes the head of the queue represented by this deque (in other words,
  --- the first element of this deque), or returns null if this deque is empty.
  native poll :: Mutable s (Deque e) -> ST s e

  --- Retrieves and removes the first element of this deque, or returns null if this deque is empty.
  native pollFirst :: Mutable s (Deque e) -> ST s e

  --- Retrieves and removes the last element of this deque, or returns null if this deque is empty.
  native pollLast :: Mutable s (Deque e) -> ST s e

  --- Pops an element from the stack represented by this deque.
  native pop :: Mutable s (Deque e) -> ST s e

  --- Pushes an element onto the stack represented by this deque (in other words, at the head of this deque)
  --- if it is possible to do so immediately without violating capacity restrictions, returning true upon success
  --- and throwing an IllegalStateException if no space is currently available.
  native push :: Mutable s (Deque e) -> e -> ST s ()

  --- Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque) or
  --- Removes the first occurrence of the specified element from this deque.
  native remove :: Mutable s (Deque e) -> ST s e
                 | Mutable s (Deque e) -> Object -> ST s Bool

  --- Retrieves and removes the first element of this deque.
  native removeFirst :: Mutable s (Deque e) -> ST s e

  --- Removes the first occurrence of the specified element from this deque.
  native removeFirstOccurrence :: Mutable s (Deque e) -> Object -> ST s Bool

  --- Retrieves and removes the last element of this deque.
  native removeLast :: Mutable s (Deque e) -> ST s e

  --- Removes the last occurrence of the specified element from this deque.
  native removeLastOccurrence :: Mutable s (Deque e) -> Object -> ST s Bool

  --- Returns the number of elements in this deque.
  native size :: Mutable s (Deque e) -> ST s Int

{--
 This class provides a skeletal implementation of the List interface to minimize the effort required to implement
 this interface backed by a "sequential access" data store (such as a linked list). For random access data (such as an array),
 AbstractList should be used in preference to this class.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractSequentialList.html AbstractSequentialList JavaDoc'
-}
data AbstractSequentialList e = native java.util.AbstractSequentialList where

  --- Inserts the specified element at the specified position in this list (optional operation).
  native add :: Mutable s (AbstractSequentialList e) -> Int -> e -> ST s ()

  --- Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
  native addAll :: Mutable s (AbstractSequentialList e) -> Int -> Mutable s (Collection e) -> ST s Bool

  --- Returns the element at the specified position in this list.
  native get :: Mutable s (AbstractSequentialList e) -> Int -> ST s e

  --- Returns an iterator over the elements in this list (in proper sequence).
  native iterator :: Mutable s (AbstractSequentialList e) -> STMutable s (Iterator e)

  --- Returns a list iterator over the elements in this list (in proper sequence).
  native listIterator :: Mutable s (AbstractSequentialList e) -> Int -> STMutable s (ListIterator e)

  --- Removes the element at the specified position in this list (optional operation).
  native remove :: Mutable s (AbstractSequentialList e) -> Int -> ST s e

  --- Replaces the element at the specified position in this list with the specified element (optional operation).
  native set :: Mutable s (AbstractSequentialList e) -> Int -> e -> ST s e

{--
 An interpreter for printf-style format strings.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html Formatter JavaDoc'
-}
data Formatter = native java.util.Formatter where

  native new :: File -> String -> IOMutable Formatter throws FileNotFoundException, UnsupportedEncodingException
              | File -> IOMutable Formatter throws FileNotFoundException
              | String -> String -> Locale -> STMutable s Formatter throws FileNotFoundException, UnsupportedEncodingException
              | String -> String -> STMutable s Formatter throws FileNotFoundException, UnsupportedEncodingException
              | String -> STMutable s Formatter throws FileNotFoundException
              | MutableIO OutputStream -> String -> IOMutable Formatter throws UnsupportedEncodingException
              | MutableIO OutputStream -> IOMutable Formatter
              | MutableIO PrintStream -> IOMutable Formatter
              | File -> String -> Locale -> IOMutable Formatter throws FileNotFoundException, UnsupportedEncodingException
              | () -> STMutable s Formatter
              | MutableIO OutputStream -> String -> Locale -> IOMutable Formatter throws UnsupportedEncodingException
              | Mutable s Appendable -> Locale -> STMutable s Formatter
              | Locale -> STMutable s Formatter
              | Mutable s Appendable -> STMutable s Formatter

  --- Closes this formatter.
  native close :: Mutable s Formatter -> ST s ()

  --- Flushes this formatter.
  native flush :: Mutable s Formatter -> ST s ()

  --- Writes a formatted string to this object's destination using the specified locale, format string, and arguments
  --- or Writes a formatted string to this object's destination using the specified format string and arguments.
  native format :: Mutable s Formatter -> String -> Mutable s (JArray Object) -> STMutable s Formatter
                 | Mutable s Formatter -> Locale -> String -> Mutable s (JArray Object) -> STMutable s Formatter

  --- Returns the IOException last thrown by this formatter's Appendable.
  native ioException :: Mutable s Formatter -> ST s IOException

  --- Returns the locale set by the construction of this formatter.
  native locale :: Mutable s Formatter -> ST s Locale

  --- Returns the destination for the output.
  native out :: Mutable s Formatter -> STMutable s Appendable

  --- Returns the result of invoking toString() on the destination for the output.
  native toString :: Mutable s Formatter -> ST s String

{--
 An unbounded priority queue based on a priority heap.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html PriorityQueue JavaDoc'
-}
data PriorityQueue e = native java.util.PriorityQueue where

  native new :: Mutable s (SortedSet e) -> STMutable s (PriorityQueue e)
              | Mutable s (PriorityQueue e) -> STMutable s (PriorityQueue e)
              | Mutable s (Collection e) -> STMutable s (PriorityQueue e)
              | () -> STMutable s (PriorityQueue e)
              | Int -> STMutable s (PriorityQueue e)
              | Int -> Comparator e -> STMutable s (PriorityQueue e)

  native add :: Mutable s (PriorityQueue e) -> e -> ST s Bool

  native clear :: Mutable s (PriorityQueue e) -> ST s ()

  native comparator :: Mutable s (PriorityQueue e) -> ST s (Comparator (≥e))

  native contains :: Mutable s (PriorityQueue e) -> Object -> ST s Bool

  native iterator :: Mutable s (PriorityQueue e) -> STMutable s (Iterator e)

  native offer :: Mutable s (PriorityQueue e) -> e -> ST s Bool

  native peek :: Mutable s (PriorityQueue e) -> ST s e

  native poll :: Mutable s (PriorityQueue e) -> ST s e

  native remove :: Mutable s (PriorityQueue e) -> Object -> ST s Bool

  native size :: Mutable s (PriorityQueue e) -> ST s Int

  native toArray :: Mutable s (PriorityQueue e) -> STMutable s (JArray Object)
                  | Mutable s (PriorityQueue e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

instance Serializable (PriorityQueue e)

{--
 A SortedMap extended with navigation methods returning the closest matches for given search targets.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/NavigableMap.html NavigableMap JavaDoc'
-}
data NavigableMap k v = native java.util.NavigableMap where

  native ceilingEntry :: Mutable s (NavigableMap k v) -> k -> STMutable s (MapEntry k v)

  native ceilingKey :: Mutable s (NavigableMap k v) -> k -> ST s k

  native descendingKeySet :: Mutable s (NavigableMap k v) -> STMutable s (NavigableSet k)

  native descendingMap :: Mutable s (NavigableMap k v) -> STMutable s (NavigableMap k v)

  native firstEntry :: Mutable s (NavigableMap k v) -> STMutable s (MapEntry k v)

  native floorEntry :: Mutable s (NavigableMap k v) -> k -> STMutable s (MapEntry k v)

  native floorKey :: Mutable s (NavigableMap k v) -> k -> ST s k

  native headMap :: Mutable s (NavigableMap k v) -> k -> Bool -> STMutable s (NavigableMap k v)
                  | Mutable s (NavigableMap k v) -> k -> STMutable s (SortedMap k v)

  native higherEntry :: Mutable s (NavigableMap k v) -> k -> STMutable s (MapEntry k v)

  native higherKey :: Mutable s (NavigableMap k v) -> k -> ST s k

  native lastEntry :: Mutable s (NavigableMap k v) -> STMutable s (MapEntry k v)

  native lowerEntry :: Mutable s (NavigableMap k v) -> k -> STMutable s (MapEntry k v)

  native lowerKey :: Mutable s (NavigableMap k v) -> k -> ST s k

  native navigableKeySet :: Mutable s (NavigableMap k v) -> STMutable s (NavigableSet k)

  native pollFirstEntry :: Mutable s (NavigableMap k v) -> STMutable s (MapEntry k v)

  native pollLastEntry :: Mutable s (NavigableMap k v) -> STMutable s (MapEntry k v)

  native subMap :: Mutable s (NavigableMap k v) -> k -> k -> STMutable s (SortedMap k v)
                 | Mutable s (NavigableMap k v) -> k -> Bool -> k -> Bool -> STMutable s (NavigableMap k v)

  native tailMap :: Mutable s (NavigableMap k v) -> k -> Bool -> STMutable s (NavigableMap k v)
                  | Mutable s (NavigableMap k v) -> k -> STMutable s (SortedMap k v)

{--
 A tagging interface that all event listener interfaces must extend.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/EventListener.html JavaDoc'
-}
data EventListener = native java.util.EventListener

{--
 Hash table and linked list implementation of the Map interface, with predictable iteration order.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html JavaDoc'
-}
data LinkedHashMap k v = native java.util.LinkedHashMap where

  native new :: Int -> Float -> Bool -> STMutable s (LinkedHashMap k v)
              | Mutable s (Map k v) -> STMutable s (LinkedHashMap k v)
              | () -> STMutable s (LinkedHashMap k v)
              | Int -> STMutable s (LinkedHashMap k v)
              | Int -> Float -> STMutable s (LinkedHashMap k v)

  native clear :: Mutable s (LinkedHashMap k v) -> ST s ()

  native containsValue :: Mutable s (LinkedHashMap k v) -> k -> ST s Bool

  native get :: Mutable s (LinkedHashMap k v) -> k -> ST s (Maybe v)

  fromList :: [(k, v)] -> STMutable s (LinkedHashMap k v)
  fromList xs = do
    m <- LinkedHashMap.new ()
    m.addAllFromList xs
    return m

instance Serializable (LinkedHashMap k v)


data FormatterBigDecimalLayoutForm = pure native java.util.Formatter.BigDecimalLayoutForm where

  pure native scientific java.util.Formatter.BigDecimalLayoutForm.SCIENTIFIC :: FormatterBigDecimalLayoutForm
  pure native decimal_float java.util.Formatter.BigDecimalLayoutForm.DECIMAL_FLOAT :: FormatterBigDecimalLayoutForm

  pure native valueOf java.util.Formatter.BigDecimalLayoutForm.valueOf :: String -> FormatterBigDecimalLayoutForm

  native values java.util.Formatter.BigDecimalLayoutForm.values :: () -> STMutable s (JArray FormatterBigDecimalLayoutForm)

instance Serializable FormatterBigDecimalLayoutForm

instance ArrayElement FormatterBigDecimalLayoutForm where
    native javaClass "java.util.Formatter.BigDecimalLayoutForm.class" :: Class FormatterBigDecimalLayoutForm

{--
 Resizable-array implementation of the Deque interface.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html JavaDoc'
-}
data ArrayDeque e = native java.util.ArrayDeque where

  native new :: () -> STMutable s (ArrayDeque e)
              | Int -> STMutable s (ArrayDeque e)
              | Mutable s (Collection e) -> STMutable s (ArrayDeque e)

  native add :: Mutable s (ArrayDeque e) -> e -> ST s Bool

  native addFirst :: Mutable s (ArrayDeque e) -> e -> ST s ()

  native addLast :: Mutable s (ArrayDeque e) -> e -> ST s ()

  native clear :: Mutable s (ArrayDeque e) -> ST s ()

  native clone :: Mutable s (ArrayDeque e) -> STMutable s (ArrayDeque e)

  native contains :: Mutable s (ArrayDeque e) -> Object -> ST s Bool

  native descendingIterator :: Mutable s (ArrayDeque e) -> STMutable s (Iterator e)

  native element :: Mutable s (ArrayDeque e) -> ST s e

  native getFirst :: Mutable s (ArrayDeque e) -> ST s e

  native getLast :: Mutable s (ArrayDeque e) -> ST s e

  native isEmpty :: Mutable s (ArrayDeque e) -> ST s Bool

  native iterator :: Mutable s (ArrayDeque e) -> STMutable s (Iterator e)

  native offer :: Mutable s (ArrayDeque e) -> e -> ST s Bool

  native offerFirst :: Mutable s (ArrayDeque e) -> e -> ST s Bool

  native offerLast :: Mutable s (ArrayDeque e) -> e -> ST s Bool

  native peek :: Mutable s (ArrayDeque e) -> ST s e

  native peekFirst :: Mutable s (ArrayDeque e) -> ST s e

  native peekLast :: Mutable s (ArrayDeque e) -> ST s e

  native poll :: Mutable s (ArrayDeque e) -> ST s e

  native pollFirst :: Mutable s (ArrayDeque e) -> ST s e

  native pollLast :: Mutable s (ArrayDeque e) -> ST s e

  native pop :: Mutable s (ArrayDeque e) -> ST s e

  native push :: Mutable s (ArrayDeque e) -> e -> ST s ()

  native remove :: Mutable s (ArrayDeque e) -> Object -> ST s Bool
                 | Mutable s (ArrayDeque e) -> ST s e

  native removeFirst :: Mutable s (ArrayDeque e) -> ST s e

  native removeFirstOccurrence :: Mutable s (ArrayDeque e) -> Object -> ST s Bool

  native removeLast :: Mutable s (ArrayDeque e) -> ST s e

  native removeLastOccurrence :: Mutable s (ArrayDeque e) -> Object -> ST s Bool

  native size :: Mutable s (ArrayDeque e) -> ST s Int

  native toArray :: Mutable s (ArrayDeque e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)
                  | Mutable s (ArrayDeque e) -> STMutable s (JArray Object)

instance Serializable (ArrayDeque e)

{--
 Enum for locale categories. These locale categories are used to get/set the default locale for the
 specific functionality represented by the category.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Locale.Category.html JavaDoc'
-}
data LocaleCategory = pure native java.util.Locale.Category where

  pure native display java.util.Locale.Category.DISPLAY :: LocaleCategory
  pure native format java.util.Locale.Category.FORMAT :: LocaleCategory

  pure native valueOf java.util.Locale.Category.valueOf :: String -> LocaleCategory

  native values java.util.Locale.Category.values :: () -> STMutable s (JArray LocaleCategory)

instance Serializable LocaleCategory

instance ArrayElement LocaleCategory where
  native javaClass "java.util.Locale.Category.class" :: Class LocaleCategory

{--
 This class implements the Map interface with a hash table, using reference-equality in place of
 object-equality when comparing keys (and values).

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/IdentityHashMap.html JavaDoc'
-}
data IdentityHashMap k v = native java.util.IdentityHashMap where

  native new :: Int -> STMutable s (IdentityHashMap k v)
              | () -> STMutable s (IdentityHashMap k v)
              | Mutable s (Map k v) -> STMutable s (IdentityHashMap k v)

  native clear :: Mutable s (IdentityHashMap k v) -> ST s ()

  native clone :: Mutable s (IdentityHashMap k v) -> ST s Object

  native containsKey :: Mutable s (IdentityHashMap k v) -> Object -> ST s Bool

  native containsValue :: Mutable s (IdentityHashMap k v) -> Object -> ST s Bool

  native entrySet :: Mutable s (IdentityHashMap k v) -> STMutable s (Set (MapEntry k v))

  native equals :: Mutable s (IdentityHashMap k v) -> Object -> ST s Bool

  native get :: Mutable s (IdentityHashMap k v) -> Object -> ST s v

  native hashCode :: Mutable s (IdentityHashMap k v) -> ST s Int

  native isEmpty :: Mutable s (IdentityHashMap k v) -> ST s Bool

  native keySet :: Mutable s (IdentityHashMap k v) -> STMutable s (Set k)

  native put :: Mutable s (IdentityHashMap k v) -> k -> v -> ST s v

  native putAll :: Mutable s (IdentityHashMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (IdentityHashMap k v) -> Object -> ST s v

  native size :: Mutable s (IdentityHashMap k v) -> ST s Int

  native values :: Mutable s (IdentityHashMap k v) -> STMutable s (Collection v)

  fromList :: [(k, v)] -> STMutable s (IdentityHashMap k v)
  fromList xs = do
    m <- IdentityHashMap.new ()
    m.addAllFromList xs
    return m

instance Serializable (IdentityHashMap k v)

{--
 A SortedSet extended with navigation methods reporting closest matches for given search targets.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/NavigableSet.html JavaDoc'
-}
data NavigableSet e = native java.util.NavigableSet where

  native ceiling :: Mutable s (NavigableSet e) -> e -> ST s e

  native descendingIterator :: Mutable s (NavigableSet e) -> STMutable s (Iterator e)

  native descendingSet :: Mutable s (NavigableSet e) -> STMutable s (NavigableSet e)

  native floor :: Mutable s (NavigableSet e) -> e -> ST s e

  native headSet :: Mutable s (NavigableSet e) -> e -> Bool -> STMutable s (NavigableSet e)
                  | Mutable s (NavigableSet e) -> e -> STMutable s (SortedSet e)

  native higher :: Mutable s (NavigableSet e) -> e -> ST s e

  native iterator :: Mutable s (NavigableSet e) -> STMutable s (Iterator e)

  native lower :: Mutable s (NavigableSet e) -> e -> ST s e

  native pollFirst :: Mutable s (NavigableSet e) -> ST s e

  native pollLast :: Mutable s (NavigableSet e) -> ST s e

  native subSet :: Mutable s (NavigableSet e) -> e -> Bool -> e -> Bool -> STMutable s (NavigableSet e)
                 | Mutable s (NavigableSet e) -> e -> e -> STMutable s (SortedSet e)

  native tailSet :: Mutable s (NavigableSet e) -> e -> Bool -> STMutable s (NavigableSet e)
                  | Mutable s (NavigableSet e) -> e -> STMutable s (SortedSet e)

{--
 Hash table and linked list implementation of the Set interface, with predictable iteration order.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashSet.html JavaDoc'
-}
data LinkedHashSet e = native java.util.LinkedHashSet where

  native new :: Mutable s (Collection e) -> STMutable s (LinkedHashSet e)
              | () -> STMutable s (LinkedHashSet e)
              | Int -> STMutable s (LinkedHashSet e)
              | Int -> Float -> STMutable s (LinkedHashSet e)

instance Serializable (LinkedHashSet e)

{--
 An Entry maintaining a key and a value.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.SimpleEntry.html JavaDoc'
-}
data AbstractMapSimpleEntry k v = native java.util.AbstractMap.SimpleEntry where

  native new :: k -> v -> STMutable s (AbstractMapSimpleEntry k v)
              | Mutable s (MapEntry k v) -> STMutable s (AbstractMapSimpleEntry k v)

  native equals :: Mutable s (AbstractMapSimpleEntry k v) -> Object -> ST s Bool

  native getKey :: Mutable s (AbstractMapSimpleEntry k v) -> ST s k

  native getValue :: Mutable s (AbstractMapSimpleEntry k v) -> ST s v

  native hashCode :: Mutable s (AbstractMapSimpleEntry k v) -> ST s Int

  native setValue :: Mutable s (AbstractMapSimpleEntry k v) -> v -> ST s v

  native toString :: Mutable s (AbstractMapSimpleEntry k v) -> ST s String

instance Serializable (AbstractMapSimpleEntry k v)

{--
 This class provides skeletal implementations of some Queue operations.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractQueue.html JavaDoc'
-}
data AbstractQueue e = native java.util.AbstractQueue where

  native add :: Mutable s (AbstractQueue e) -> e -> ST s Bool

  native addAll :: Mutable s (AbstractQueue e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (AbstractQueue e) -> ST s ()

  native element :: Mutable s (AbstractQueue e) -> ST s e

  native remove :: Mutable s (AbstractQueue e) -> ST s e

{--
 This class provides a skeletal implementation of the List interface to minimize the effort required to
 implement this interface backed by a "random access" data store (such as an array).

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractList.html JavaDoc'
-}
data AbstractList e = native java.util.AbstractList where

  native add :: Mutable s (AbstractList e) -> Int -> e -> ST s ()
              | Mutable s (AbstractList e) -> e -> ST s Bool

  native addAll :: Mutable s (AbstractList e) -> Int -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (AbstractList e) -> ST s ()

  native equals :: Mutable s (AbstractList e) -> Object -> ST s Bool

  native get :: Mutable s (AbstractList e) -> Int -> ST s e

  native hashCode :: Mutable s (AbstractList e) -> ST s Int

  native indexOf :: Mutable s (AbstractList e) -> Object -> ST s Int

  native iterator :: Mutable s (AbstractList e) -> STMutable s (Iterator e)

  native lastIndexOf :: Mutable s (AbstractList e) -> Object -> ST s Int

  native listIterator :: Mutable s (AbstractList e) -> STMutable s (ListIterator e)
                       | Mutable s (AbstractList e) -> Int -> STMutable s (ListIterator e)

  native remove :: Mutable s (AbstractList e) -> Int -> ST s e

  native set :: Mutable s (AbstractList e) -> Int -> e -> ST s e

  native subList :: Mutable s (AbstractList e) -> Int -> Int -> STMutable s (List e)

{--
 Hash table based implementation of the Map interface.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html JavaDoc'
-}
data HashMap k v = native java.util.HashMap where

  native new :: Mutable s (Map k v) -> STMutable s (HashMap k v)
              | () -> STMutable s (HashMap k v)
              | Int -> STMutable s (HashMap k v)
              | Int -> Float -> STMutable s (HashMap k v)

  native clear :: Mutable s (HashMap k v) -> ST s ()

  native containsKey :: Mutable s (HashMap k v) -> k -> ST s Bool

  native containsValue :: Mutable s (HashMap k v) -> k -> ST s Bool

  native entrySet :: Mutable s (HashMap k v) -> STMutable s (Set (Mutable s (MapEntry k v)))

  native get :: Mutable s (HashMap k v) -> k -> ST s (Maybe v)

  native isEmpty :: Mutable s (HashMap k v) -> ST s Bool

  native keySet :: Mutable s (HashMap k v) -> STMutable s (Set k)

  native put :: Mutable s (HashMap k v) -> k -> v -> ST s (Maybe v)

  native putAll :: Mutable s (HashMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (HashMap k v) -> k -> ST s v

  native size :: Mutable s (HashMap k v) -> ST s Int

  native values :: Mutable s (HashMap k v) -> STMutable s (Collection v)

  fromList :: [(k, v)] -> STMutable s (HashMap k v)
  fromList xs = do
    m <- HashMap.new ()
    m.addAllFromList xs
    return m

instance Serializable (HashMap k v)

{--
 A Red-Black tree based 'https://docs.oracle.com/javase/7/docs/api/java/util/NavigableMap.html NavigableMap' implementation.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/TreeMap.html JavaDoc'
-}
data TreeMap k v = native java.util.TreeMap where

  native new :: Mutable s (SortedMap k v) -> STMutable s (TreeMap k v)
              | Mutable s (Map k v) -> STMutable s (TreeMap k v)
              | Comparator k -> STMutable s (TreeMap k v)
              | () -> STMutable s (TreeMap k v)

  native ceilingEntry :: Mutable s (TreeMap k v) -> k -> STMutable s (MapEntry k v)

  native ceilingKey :: Mutable s (TreeMap k v) -> k -> ST s k

  native clear :: Mutable s (TreeMap k v) -> ST s ()

  native comparator :: Mutable s (TreeMap k v) -> ST s (Comparator (≥k))

  native containsKey :: Mutable s (TreeMap k v) -> k -> ST s Bool

  native containsValue :: Mutable s (TreeMap k v) -> k -> ST s Bool

  native descendingKeySet :: Mutable s (TreeMap k v) -> STMutable s (NavigableSet k)

  native descendingMap :: Mutable s (TreeMap k v) -> STMutable s (NavigableMap k v)

  native entrySet :: Mutable s (TreeMap k v) -> STMutable s (Set (MapEntry k v))

  native firstEntry :: Mutable s (TreeMap k v) -> STMutable s (MapEntry k v)

  native firstKey :: Mutable s (TreeMap k v) -> ST s k

  native floorEntry :: Mutable s (TreeMap k v) -> k -> STMutable s (MapEntry k v)

  native floorKey :: Mutable s (TreeMap k v) -> k -> ST s k

  native get :: Mutable s (TreeMap k v) -> k -> ST s (Maybe v)

  native headMap :: Mutable s (TreeMap k v) -> k -> Bool -> STMutable s (NavigableMap k v)
                  | Mutable s (TreeMap k v) -> k -> STMutable s (SortedMap k v)

  native higherEntry :: Mutable s (TreeMap k v) -> k -> STMutable s (MapEntry k v)

  native higherKey :: Mutable s (TreeMap k v) -> k -> ST s k

  native keySet :: Mutable s (TreeMap k v) -> STMutable s (Set k)

  native lastEntry :: Mutable s (TreeMap k v) -> STMutable s (MapEntry k v)

  native lastKey :: Mutable s (TreeMap k v) -> ST s k

  native lowerEntry :: Mutable s (TreeMap k v) -> k -> STMutable s (MapEntry k v)

  native lowerKey :: Mutable s (TreeMap k v) -> k -> ST s k

  native navigableKeySet :: Mutable s (TreeMap k v) -> STMutable s (NavigableSet k)

  native pollFirstEntry :: Mutable s (TreeMap k v) -> STMutable s (MapEntry k v)

  native pollLastEntry :: Mutable s (TreeMap k v) -> STMutable s (MapEntry k v)

  native put :: Mutable s (TreeMap k v) -> k -> v -> ST s v

  native putAll :: Mutable s (TreeMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (TreeMap k v) -> k -> ST s (Maybe v)

  native size :: Mutable s (TreeMap k v) -> ST s Int

  native subMap :: Mutable s (TreeMap k v) -> k -> Bool -> k -> Bool -> STMutable s (NavigableMap k v)
                 | Mutable s (TreeMap k v) -> k -> k -> STMutable s (SortedMap k v)

  native tailMap :: Mutable s (TreeMap k v) -> k -> Bool -> STMutable s (NavigableMap k v)
                  | Mutable s (TreeMap k v) -> k -> STMutable s (SortedMap k v)

  native values :: Mutable s (TreeMap k v) -> STMutable s (Collection v)

  fromList :: [(k, v)] -> STMutable s (TreeMap k v)
  fromList xs = do
    m <- TreeMap.new ()
    m.addAllFromList xs
    return m

instance Serializable (TreeMap k v)

{--
 A collection designed for holding elements prior to processing.
 Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html JavaDoc'
-}
data Queue e = native java.util.Queue where

  native add :: Mutable s (Queue e) -> e -> ST s Bool

  native element :: Mutable s (Queue e) -> ST s e

  native offer :: Mutable s (Queue e) -> e -> ST s Bool

  native peek :: Mutable s (Queue e) -> ST s e

  native poll :: Mutable s (Queue e) -> ST s e

  native remove :: Mutable s (Queue e) -> ST s e

{--
 This class provides a skeletal implementation of the Collection interface, to minimize the effort required to
 implement this interface.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractCollection.html JavaDoc'
-}
data AbstractCollection e = native java.util.AbstractCollection where

  native add :: Mutable s (AbstractCollection e) -> e -> ST s Bool

  native addAll :: Mutable s (AbstractCollection e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (AbstractCollection e) -> ST s ()

  native contains :: Mutable s (AbstractCollection e) -> Object -> ST s Bool

  native containsAll :: Mutable s (AbstractCollection e) -> Mutable s (Collection Object) -> ST s Bool

  native isEmpty :: Mutable s (AbstractCollection e) -> ST s Bool

  native iterator :: Mutable s (AbstractCollection e) -> STMutable s (Iterator e)

  native remove :: Mutable s (AbstractCollection e) -> e -> ST s Bool

  native removeAll :: Mutable s (AbstractCollection e) -> Mutable s (Collection Object) -> ST s Bool

  native retainAll :: Mutable s (AbstractCollection e) -> Mutable s (Collection Object) -> ST s Bool

  native size :: Mutable s (AbstractCollection e) -> ST s Int

  native toArray :: Mutable s (AbstractCollection e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)
                  | Mutable s (AbstractCollection e) -> STMutable s (JArray Object)

  native toString :: Mutable s (AbstractCollection e) -> ST s String

{--
 This class implements the Set interface, backed by a hash table (actually a HashMap instance).
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html JavaDoc'
-}
data HashSet e = native java.util.HashSet where

  native new :: Int -> STMutable s (HashSet e)
              | Int -> Float -> STMutable s (HashSet e)
              | Mutable s (Collection e) -> STMutable s (HashSet e)
              | () -> STMutable s (HashSet e)

  native add :: Mutable s (HashSet e) -> e -> ST s Bool

  native clear :: Mutable s (HashSet e) -> ST s ()

  native clone :: Mutable s (HashSet e) -> ST s Object

  native contains :: Mutable s (HashSet e) -> Object -> ST s Bool

  native isEmpty :: Mutable s (HashSet e) -> ST s Bool

  native iterator :: Mutable s (HashSet e) -> STMutable s (Iterator e)

  native remove :: Mutable s (HashSet e) -> e -> ST s Bool

  native size :: Mutable s (HashSet e) -> ST s Int

instance Serializable (HashSet e)

{--
 A @Locale@ object represents a specific geographical, political, or cultural region.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html JavaDoc'
-}
data Locale = pure native java.util.Locale where

  pure native english java.util.Locale.ENGLISH :: Locale
  pure native french java.util.Locale.FRENCH :: Locale
  pure native german java.util.Locale.GERMAN :: Locale
  pure native italian java.util.Locale.ITALIAN :: Locale
  pure native japanese java.util.Locale.JAPANESE :: Locale
  pure native korean java.util.Locale.KOREAN :: Locale
  pure native chinese java.util.Locale.CHINESE :: Locale
  pure native simplified_chinese java.util.Locale.SIMPLIFIED_CHINESE :: Locale
  pure native traditional_chinese java.util.Locale.TRADITIONAL_CHINESE :: Locale
  pure native france java.util.Locale.FRANCE :: Locale
  pure native germany java.util.Locale.GERMANY :: Locale
  pure native italy java.util.Locale.ITALY :: Locale
  pure native japan java.util.Locale.JAPAN :: Locale
  pure native korea java.util.Locale.KOREA :: Locale
  pure native china java.util.Locale.CHINA :: Locale
  pure native prc java.util.Locale.PRC :: Locale
  pure native taiwan java.util.Locale.TAIWAN :: Locale
  pure native uk java.util.Locale.UK :: Locale
  pure native us java.util.Locale.US :: Locale
  pure native canada java.util.Locale.CANADA :: Locale
  pure native canada_french java.util.Locale.CANADA_FRENCH :: Locale
  pure native root java.util.Locale.ROOT :: Locale
  pure native private_use_extension java.util.Locale.PRIVATE_USE_EXTENSION :: Char
  pure native unicode_locale_extension java.util.Locale.UNICODE_LOCALE_EXTENSION :: Char

  --- Create a 'Locale' like so:
  --- > Locale.new "de"
  --- > Locale.new "de" "AT"
  pure native new :: String -> Locale
              | String -> String -> Locale
              | String -> String -> String -> Locale

  pure native clone :: Locale -> Object

  pure native equals :: Locale -> Object -> Bool

  pure native forLanguageTag java.util.Locale.forLanguageTag :: String -> Locale

  native getAvailableLocales java.util.Locale.getAvailableLocales :: () -> STMutable s (JArray Locale)

  pure native getCountry :: Locale -> String

  native getDefault java.util.Locale.getDefault :: LocaleCategory -> ST s Locale
                                                 | () -> ST s Locale

  pure native getDisplayCountry :: Locale -> String
                                 | Locale -> Locale -> String

  pure native getDisplayLanguage :: Locale -> String
                                  | Locale -> Locale -> String

  pure native getDisplayName :: Locale -> Locale -> String
                              | Locale -> String

  pure native getDisplayScript :: Locale -> String
                                | Locale -> Locale -> String

  pure native getDisplayVariant :: Locale -> Locale -> String
                                 | Locale -> String

  pure native getExtension :: Locale -> Char -> String

  native getExtensionKeys :: Locale -> STMutable s (Set Character)

  pure native getISO3Country :: Locale -> String

  pure native getISO3Language :: Locale -> String

  native getISOCountries java.util.Locale.getISOCountries :: () -> STMutable s (JArray String)

  native getISOLanguages java.util.Locale.getISOLanguages :: () -> STMutable s (JArray String)

  pure native getLanguage :: Locale -> String

  pure native getScript :: Locale -> String

  native getUnicodeLocaleAttributes :: Locale -> STMutable s (Set String)

  native getUnicodeLocaleKeys :: Locale -> STMutable s (Set String)

  pure native getUnicodeLocaleType :: Locale -> String -> String

  pure native getVariant :: Locale -> String

  pure native hashCode :: Locale -> Int

  native setDefault java.util.Locale.setDefault :: Locale -> ST s ()
                                                 | LocaleCategory -> Locale -> ST s ()

  pure native toLanguageTag :: Locale -> String

  pure native toString :: Locale -> String

instance Serializable Locale

derive ArrayElement Locale

instance Show Locale where show = Locale.toString    

{--
 A 'https://docs.oracle.com/javase/7/docs/api/java/util/NavigableSet.html NavigableSet' implementation based
 on a 'https://docs.oracle.com/javase/7/docs/api/java/util/TreeMap.html TreeMap'.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html JavaDoc'
-}
data TreeSet e = native java.util.TreeSet where

  native new :: Mutable s (SortedSet e) -> STMutable s (TreeSet e)
              | Mutable s (Collection e) -> STMutable s (TreeSet e)
              | Comparator e -> STMutable s (TreeSet e)
              | () -> STMutable s (TreeSet e)

  native add :: Mutable s (TreeSet e) -> e -> ST s Bool

  native addAll :: Mutable s (TreeSet e) -> Mutable s (Collection e) -> ST s Bool

  native ceiling :: Mutable s (TreeSet e) -> e -> ST s e

  native clear :: Mutable s (TreeSet e) -> ST s ()

  native clone :: Mutable s (TreeSet e) -> ST s Object

  native comparator :: Mutable s (TreeSet e) -> ST s (Comparator (≥e))

  native contains :: Mutable s (TreeSet e) -> Object -> ST s Bool

  native descendingIterator :: Mutable s (TreeSet e) -> STMutable s (Iterator e)

  native descendingSet :: Mutable s (TreeSet e) -> STMutable s (NavigableSet e)

  native first :: Mutable s (TreeSet e) -> ST s e

  native floor :: Mutable s (TreeSet e) -> e -> ST s e

  native headSet :: Mutable s (TreeSet e) -> e -> STMutable s (SortedSet e)
                  | Mutable s (TreeSet e) -> e -> Bool -> STMutable s (NavigableSet e)

  native higher :: Mutable s (TreeSet e) -> e -> ST s e

  native isEmpty :: Mutable s (TreeSet e) -> ST s Bool

  native iterator :: Mutable s (TreeSet e) -> STMutable s (Iterator e)

  native last :: Mutable s (TreeSet e) -> ST s e

  native lower :: Mutable s (TreeSet e) -> e -> ST s e

  native pollFirst :: Mutable s (TreeSet e) -> ST s e

  native pollLast :: Mutable s (TreeSet e) -> ST s e

  native remove :: Mutable s (TreeSet e) -> e -> ST s Bool

  native size :: Mutable s (TreeSet e) -> ST s Int

  native subSet :: Mutable s (TreeSet e) -> e -> e -> STMutable s (SortedSet e)
                 | Mutable s (TreeSet e) -> e -> Bool -> e -> Bool -> STMutable s (NavigableSet e)

  native tailSet :: Mutable s (TreeSet e) -> e -> Bool -> STMutable s (NavigableSet e)
                  | Mutable s (TreeSet e) -> e -> STMutable s (SortedSet e)

instance Serializable (TreeSet e)

{--
 A simple text scanner which can parse primitive types and strings using regular expressions.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html JavaDoc'
-}
data Scanner = native java.util.Scanner where

  native new :: MutableIO InputStream -> IOMutable Scanner
              | Mutable s Readable -> STMutable s Scanner
              -- MutableIO Reader -> IOMutable Scanner
              | MutableIO InputStream -> String -> IOMutable Scanner
              | File -> String -> STMutable s Scanner throws FileNotFoundException
              | File -> STMutable s Scanner throws FileNotFoundException
              | String -> STMutable s Scanner
              | Mutable s ReadableByteChannel -> STMutable s Scanner
              | Mutable s ReadableByteChannel -> String -> STMutable s Scanner
              | Path -> String -> STMutable s Scanner throws IOException
              | Path -> STMutable s Scanner throws IOException

  native close :: Mutable s Scanner -> ST s ()

  native delimiter :: Mutable s Scanner -> ST s Regex

  native findInLine :: Mutable s Scanner -> Regex -> ST s String
                     | Mutable s Scanner -> String -> ST s String

  native findWithinHorizon :: Mutable s Scanner -> String -> Int -> ST s String
                            | Mutable s Scanner -> Regex -> Int -> ST s String

  native hasNext :: Mutable s Scanner -> ST s Bool
                  | Mutable s Scanner -> String -> ST s Bool
                  | Mutable s Scanner -> Regex -> ST s Bool

  native hasNextBigDecimal :: Mutable s Scanner -> ST s Bool

  native hasNextBigInteger :: Mutable s Scanner -> Int -> ST s Bool
                            | Mutable s Scanner -> ST s Bool

  native hasNextBoolean :: Mutable s Scanner -> ST s Bool

  native hasNextByte :: Mutable s Scanner -> Int -> ST s Bool
                      | Mutable s Scanner -> ST s Bool

  native hasNextDouble :: Mutable s Scanner -> ST s Bool

  native hasNextFloat :: Mutable s Scanner -> ST s Bool

  native hasNextInt :: Mutable s Scanner -> Int -> ST s Bool
                     | Mutable s Scanner -> ST s Bool

  native hasNextLine :: Mutable s Scanner -> ST s Bool

  native hasNextLong :: Mutable s Scanner -> ST s Bool
                      | Mutable s Scanner -> Int -> ST s Bool

  native hasNextShort :: Mutable s Scanner -> Int -> ST s Bool
                       | Mutable s Scanner -> ST s Bool

  native ioException :: Mutable s Scanner -> ST s IOException

  native locale :: Mutable s Scanner -> ST s Locale

  native match :: Mutable s Scanner -> ST s MatchResult

  native next :: Mutable s Scanner -> String -> ST s String
               | Mutable s Scanner -> Regex -> ST s String
               | Mutable s Scanner -> ST s String

  native nextBigDecimal :: Mutable s Scanner -> ST s BigDecimal

  native nextBigInteger :: Mutable s Scanner -> ST s Integer
                         | Mutable s Scanner -> Int -> ST s Integer

  native nextBoolean :: Mutable s Scanner -> ST s Bool

  native nextByte :: Mutable s Scanner -> ST s Byte
                   | Mutable s Scanner -> Int -> ST s Byte

  native nextDouble :: Mutable s Scanner -> ST s Double

  native nextFloat :: Mutable s Scanner -> ST s Float

  native nextInt :: Mutable s Scanner -> ST s Int
                  | Mutable s Scanner -> Int -> ST s Int

  native nextLine :: Mutable s Scanner -> ST s String

  native nextLong :: Mutable s Scanner -> ST s Long
                   | Mutable s Scanner -> Int -> ST s Long

  native nextShort :: Mutable s Scanner -> ST s Short
                    | Mutable s Scanner -> Int -> ST s Short

  native radix :: Mutable s Scanner -> ST s Int

  native remove :: Mutable s Scanner -> ST s ()

  native reset :: Mutable s Scanner -> STMutable s Scanner

  native skip :: Mutable s Scanner -> String -> STMutable s Scanner
               | Mutable s Scanner -> Regex -> STMutable s Scanner

  native toString :: Mutable s Scanner -> ST s String

  native useDelimiter :: Mutable s Scanner -> String -> STMutable s Scanner
                       | Mutable s Scanner -> Regex -> STMutable s Scanner

  native useLocale :: Mutable s Scanner -> Locale -> STMutable s Scanner

  native useRadix :: Mutable s Scanner -> Int -> STMutable s Scanner

{--
 The root interface in the collection hierarchy.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Collection.html JavaDoc'
-}
data Collection e = native java.util.Collection where

  native add :: Mutable s (Collection e) -> e -> ST s Bool

  native addAll :: Mutable s (Collection e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (Collection e) -> ST s ()

  native contains :: Mutable s (Collection e) -> e -> ST s Bool

  native containsAll :: Mutable s (Collection e) -> Mutable s (Collection e) -> ST s Bool

  native equals :: Mutable s (Collection e) -> Mutable s (Collection e) -> ST s Bool

  native hashCode :: Mutable s (Collection e) -> ST s Int

  native isEmpty :: Mutable s (Collection e) -> ST s Bool

  native iterator :: Mutable s (Collection e) -> STMutable s (Iterator e)

  native remove :: Mutable s (Collection e) -> e -> ST s Bool

  native removeAll :: Mutable s (Collection e) -> Mutable s (Collection Object) -> ST s Bool

  native retainAll :: Mutable s (Collection e) -> Mutable s (Collection Object) -> ST s Bool

  native size :: Mutable s (Collection e) -> ST s Int

  native toArray :: Mutable s (Collection e) -> STMutable s (JArray Object)
                  | Mutable s (Collection e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

  addAllFromList :: Mutable s (Collection a) -> [a] -> ST s ()
  addAllFromList collection [] = return ()
  addAllFromList collection (x:xs) = collection.add x >> addAllFromList collection xs

  toList :: Mutable s (Collection e) -> ST s [e]
  toList collection = collection.iterator >>= Iterator.toList




{--
 A specialized Map implementation for use with enum type keys.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/EnumMap.html JavaDoc'
-}
data EnumMap (k≤JEnum k) v = native java.util.EnumMap {k,v} where
                                        

  native new :: Class k -> STMutable s (EnumMap k v)
              | Mutable s (Map k v) -> STMutable s (EnumMap k v)
              | Mutable s (EnumMap k v) -> STMutable s (EnumMap k v)

  native clear :: Mutable s (EnumMap k v) -> ST s ()

  native clone :: Mutable s (EnumMap k v) -> STMutable s (EnumMap k v)

  native containsKey :: Mutable s (EnumMap k v) -> Object -> ST s Bool

  native containsValue :: Mutable s (EnumMap k v) -> Object -> ST s Bool

  native entrySet :: Mutable s (EnumMap k v) -> STMutable s (Set (MapEntry k v))

  native equals :: Mutable s (EnumMap k v) -> Mutable s (EnumMap k v) -> ST s Bool

  native get :: Mutable s (EnumMap k v) -> k -> ST s (Maybe v)

  native hashCode :: forall (k≤JEnum k) s v . Mutable s (EnumMap k v) -> ST s Int

  native keySet :: Mutable s (EnumMap k v) -> STMutable s (Set k)

  native put :: Mutable s (EnumMap k v) -> k -> v -> ST s (Maybe v)

  native putAll :: Mutable s (EnumMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (EnumMap k v) -> k -> ST s (Maybe v)

  native size :: Mutable s (EnumMap k v) -> ST s Int

  native values :: Mutable s (EnumMap k v) -> STMutable s (Collection v)

instance Serializable (EnumMap k v)

{-

    warning: [deprecation] save(OutputStream,String) in Properties has been deprecated

 A class can implement the Observer interface when it wants to be informed of changes in observable objects.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Observer.html JavaDoc'

data Observer = native java.util.Observer where

  native update{} :: Mutable s Observer -> Mutable s Observable -> a -> ST s ()
-}

{--
  Hash table based implementation of the Map interface, with weak keys.
  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/WeakHashMap.html JavaDoc'
-}
data WeakHashMap k v = native java.util.WeakHashMap where

  native new :: () -> STMutable s (WeakHashMap k v)
              | Int -> STMutable s (WeakHashMap k v)
              | Int -> Float -> STMutable s (WeakHashMap k v)
              | Mutable s (Map k v) -> STMutable s (WeakHashMap k v)

  native clear :: Mutable s (WeakHashMap k v) -> ST s ()

  native containsKey :: Mutable s (WeakHashMap k v) -> k -> ST s Bool

  native containsValue :: Mutable s (WeakHashMap k v) -> v -> ST s Bool

  native entrySet :: Mutable s (WeakHashMap k v) -> STMutable s (Set (MapEntry k v))

  native get :: Mutable s (WeakHashMap k v) -> k -> ST s (Maybe v)

  native isEmpty :: Mutable s (WeakHashMap k v) -> ST s Bool

  native keySet :: Mutable s (WeakHashMap k v) -> STMutable s (Set k)

  native put :: Mutable s (WeakHashMap k v) -> k -> v -> ST s (Maybe v)

  native putAll :: Mutable s (WeakHashMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (WeakHashMap k v) -> k -> ST s (Maybe v)

  native size :: Mutable s (WeakHashMap k v) -> ST s Int

  native values :: Mutable s (WeakHashMap k v) -> STMutable s (Collection v)

{--
  An iterator for lists that allows the programmer to traverse the list in either direction,
  modify the list during iteration, and obtain the iterator's current position in the list.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ListIterator.html JavaDoc'
-}
data ListIterator e = native java.util.ListIterator where

  native add :: Mutable s (ListIterator e) -> e -> ST s ()

  native hasNext :: Mutable s (ListIterator e) -> ST s Bool

  native hasPrevious :: Mutable s (ListIterator e) -> ST s Bool

  native next :: Mutable s (ListIterator e) -> ST s e

  native nextIndex :: Mutable s (ListIterator e) -> ST s Int

  native previous :: Mutable s (ListIterator e) -> ST s e

  native previousIndex :: Mutable s (ListIterator e) -> ST s Int

  native remove :: Mutable s (ListIterator e) -> ST s ()

  native set :: Mutable s (ListIterator e) -> e -> ST s ()

{--
 Doubly-linked list implementation of the List and Deque interfaces.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html JavaDoc'
-}
data LinkedList e = native java.util.LinkedList where

  native new :: () -> STMutable s (LinkedList e)
              | Mutable s (Collection e) -> STMutable s (LinkedList e)

  native add :: Mutable s (LinkedList e) -> e -> ST s Bool
              | Mutable s (LinkedList e) -> Int -> e -> ST s ()

  native addAll :: Mutable s (LinkedList e) -> Mutable s (Collection e) -> ST s Bool
                 | Mutable s (LinkedList e) -> Int -> Mutable s (Collection e) -> ST s Bool

  native addFirst :: Mutable s (LinkedList e) -> e -> ST s ()

  native addLast :: Mutable s (LinkedList e) -> e -> ST s ()

  native clear :: Mutable s (LinkedList e) -> ST s ()

  native clone :: Mutable s (LinkedList e) -> ST s Object

  native contains :: Mutable s (LinkedList e) -> e -> ST s Bool

  native descendingIterator :: Mutable s (LinkedList e) -> STMutable s (Iterator e)

  native element :: Mutable s (LinkedList e) -> ST s e

  native get :: Mutable s (LinkedList e) -> Int -> ST s e

  native getFirst :: Mutable s (LinkedList e) -> ST s e

  native getLast :: Mutable s (LinkedList e) -> ST s e

  native indexOf :: Mutable s (LinkedList e) -> e -> ST s Int

  native lastIndexOf :: Mutable s (LinkedList e) -> e -> ST s Int

  native listIterator :: Mutable s (LinkedList e) -> Int -> STMutable s (ListIterator e)

  native offer :: Mutable s (LinkedList e) -> e -> ST s Bool

  native offerFirst :: Mutable s (LinkedList e) -> e -> ST s Bool

  native offerLast :: Mutable s (LinkedList e) -> e -> ST s Bool

  native peek :: Mutable s (LinkedList e) -> ST s e

  native peekFirst :: Mutable s (LinkedList e) -> ST s e

  native peekLast :: Mutable s (LinkedList e) -> ST s e

  native poll :: Mutable s (LinkedList e) -> ST s e

  native pollFirst :: Mutable s (LinkedList e) -> ST s e

  native pollLast :: Mutable s (LinkedList e) -> ST s e

  native pop :: Mutable s (LinkedList e) -> ST s e

  native push :: Mutable s (LinkedList e) -> e -> ST s ()

  native remove :: Mutable s (LinkedList e) -> Int -> ST s e
                 | Mutable s (LinkedList e) -> ST s e
                 | Mutable s (LinkedList e) -> e -> ST s Bool

  native removeFirst :: Mutable s (LinkedList e) -> ST s e

  native removeFirstOccurrence :: Mutable s (LinkedList e) -> e -> ST s Bool

  native removeLast :: Mutable s (LinkedList e) -> ST s e

  native removeLastOccurrence :: Mutable s (LinkedList e) -> e -> ST s Bool

  native set :: Mutable s (LinkedList e) -> Int -> e -> ST s e

  native size :: Mutable s (LinkedList e) -> ST s Int

  native toArray :: Mutable s (LinkedList e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)
                  | Mutable s (LinkedList e) -> STMutable s (JArray Object)

  fromList :: [a] -> STMutable s (LinkedList a)
  fromList xs = do
      jlist <- LinkedList.new ()
      jlist.addAllFromList xs
      return jlist

instance Serializable (LinkedList e)

{--
 Resizable-array implementation of the List interface.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html JavaDoc'
-}
data ArrayList e = native java.util.ArrayList where

  native new :: Mutable s (Collection e) -> STMutable s (ArrayList e)
              | () -> STMutable s (ArrayList e)
              | Int -> STMutable s (ArrayList e)

  native add :: Mutable s (ArrayList e) -> Int -> e -> ST s ()
              | Mutable s (ArrayList e) -> e -> ST s Bool

  native addAll :: Mutable s (ArrayList e) -> Int -> Mutable s (Collection e) -> ST s Bool
                 | Mutable s (ArrayList e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (ArrayList e) -> ST s ()

  native clone :: Mutable s (ArrayList e) -> ST s Object

  native contains :: Mutable s (ArrayList e) -> e -> ST s Bool

  native ensureCapacity :: Mutable s (ArrayList e) -> Int -> ST s ()

  native get :: Mutable s (ArrayList e) -> Int -> ST s e

  native indexOf :: Mutable s (ArrayList e) -> e -> ST s Int

  native isEmpty :: Mutable s (ArrayList e) -> ST s Bool

  native iterator :: Mutable s (ArrayList e) -> STMutable s (Iterator e)

  native lastIndexOf :: Mutable s (ArrayList e) -> e -> ST s Int

  native listIterator :: Mutable s (ArrayList e) -> Int -> STMutable s (ListIterator e)
                       | Mutable s (ArrayList e) -> STMutable s (ListIterator e)

  native remove :: Mutable s (ArrayList e) -> Int -> ST s e
                 | Mutable s (ArrayList e) -> e -> ST s Bool

  native removeAll :: Mutable s (ArrayList e) -> Mutable s (Collection e) -> ST s Bool

  native retainAll :: Mutable s (ArrayList e) -> Mutable s (Collection e) -> ST s Bool

  native set :: Mutable s (ArrayList e) -> Int -> e -> ST s e

  native size :: Mutable s (ArrayList e) -> ST s Int

  native subList :: Mutable s (ArrayList e) -> Int -> Int -> STMutable s (List e)

  native toArray :: Mutable s (ArrayList e) -> STMutable s (JArray Object)
                  | Mutable s (ArrayList e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

  native trimToSize :: Mutable s (ArrayList e) -> ST s ()

  fromList :: [a] -> STMutable s (ArrayList a)
  fromList xs = do
      jlist <- ArrayList.new xs.length
      jlist.addAllFromList xs
      return jlist

instance Serializable (ArrayList e)

{--
 A specialized 'https://docs.oracle.com/javase/7/docs/api/java/util/Set.html Set' implementation for use with enum types.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/EnumSet.html JavaDoc'
-}
data EnumSet (e ≤ JEnum e) = native java.util.EnumSet {e} where

  native allOf java.util.EnumSet.allOf {e} :: Class e -> STMutable s (EnumSet e)

  native clone{} :: Mutable s (EnumSet e) -> STMutable s (EnumSet e)

  native complementOf java.util.EnumSet.complementOf {e} :: Mutable s (EnumSet e) -> STMutable s (EnumSet e)

  native copyOf java.util.EnumSet.copyOf {e} :: Mutable s (EnumSet e)    -> STMutable s (EnumSet e)
                                              | Mutable s (Collection e) -> STMutable s (EnumSet e)

  native noneOf java.util.EnumSet.noneOf {e} :: Class e -> STMutable s (EnumSet e)

  native from "java.util.EnumSet.of" {e} ::  e -> e -> e -> e     -> STMutable s (EnumSet e)
                                      | e -> e -> e -> e -> e     -> STMutable s (EnumSet e)
                                      | e -> Mutable s (JArray e) -> STMutable s (EnumSet e)
                                      | e                         -> STMutable s (EnumSet e)
                                      | e -> e                    -> STMutable s (EnumSet e)
                                      | e -> e -> e               -> STMutable s (EnumSet e)

  native range java.util.EnumSet.range {e} :: e -> e -> STMutable s (EnumSet e)

instance Serializable (EnumSet e)


{--
 The Vector class implements a growable array of objects.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Vector.html JavaDoc'
-}
data Vector e = native java.util.Vector where

  native new :: Mutable s (Collection e) -> STMutable s (Vector e)
              | () -> STMutable s (Vector e)
              | Int -> STMutable s (Vector e)
              | Int -> Int -> STMutable s (Vector e)

  native add :: Mutable s (Vector e) -> e -> ST s Bool
              | Mutable s (Vector e) -> Int -> e -> ST s ()

  native addAll :: Mutable s (Vector e) -> Int -> Mutable s (Collection e) -> ST s Bool
                 | Mutable s (Vector e) -> Mutable s (Collection e) -> ST s Bool

  native addElement :: Mutable s (Vector e) -> e -> ST s ()

  native capacity :: Mutable s (Vector e) -> ST s Int

  native clear :: Mutable s (Vector e) -> ST s ()

  native clone :: Mutable s (Vector e) -> ST s Object

  native contains :: Mutable s (Vector e) -> e -> ST s Bool

  native containsAll :: Mutable s (Vector e) -> Mutable s (Collection e) -> ST s Bool

  native copyInto :: Mutable s (Vector e) -> Mutable s (JArray Object) -> ST s ()

  native elementAt :: Mutable s (Vector e) -> Int -> ST s e

  native elements :: Mutable s (Vector e) -> STMutable s (Enumeration e)

  native ensureCapacity :: Mutable s (Vector e) -> Int -> ST s ()

  native equals :: Mutable s (Vector e) -> e -> ST s Bool

  native firstElement :: Mutable s (Vector e) -> ST s e

  native get :: Mutable s (Vector e) -> Int -> ST s e

  native hashCode :: Mutable s (Vector e) -> ST s Int

  native indexOf :: Mutable s (Vector e) -> e -> ST s Int
                  | Mutable s (Vector e) -> e -> Int -> ST s Int

  native insertElementAt :: Mutable s (Vector e) -> e -> Int -> ST s ()

  native isEmpty :: Mutable s (Vector e) -> ST s Bool

  native iterator :: Mutable s (Vector e) -> STMutable s (Iterator e)

  native lastElement :: Mutable s (Vector e) -> ST s e

  native lastIndexOf :: Mutable s (Vector e) -> e -> Int -> ST s Int
                      | Mutable s (Vector e) -> e -> ST s Int

  native listIterator :: Mutable s (Vector e) -> STMutable s (ListIterator e)
                       | Mutable s (Vector e) -> Int -> STMutable s (ListIterator e)

  native remove :: Mutable s (Vector e) -> e -> ST s Bool
                 | Mutable s (Vector e) -> Int -> ST s e

  native removeAll :: Mutable s (Vector e) -> Mutable s (Collection e) -> ST s Bool

  native removeAllElements :: Mutable s (Vector e) -> ST s ()

  native removeElement :: Mutable s (Vector e) -> e -> ST s Bool

  native removeElementAt :: Mutable s (Vector e) -> Int -> ST s ()

  native retainAll :: Mutable s (Vector e) -> Mutable s (Collection e) -> ST s Bool

  native set :: Mutable s (Vector e) -> Int -> e -> ST s e

  native setElementAt :: Mutable s (Vector e) -> e -> Int -> ST s ()

  native setSize :: Mutable s (Vector e) -> Int -> ST s ()

  native size :: Mutable s (Vector e) -> ST s Int

  native subList :: Mutable s (Vector e) -> Int -> Int -> STMutable s (List e)

  native toArray :: Mutable s (Vector e) -> STMutable s (JArray Object)
                  | Mutable s (Vector e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

  native toString :: Mutable s (Vector e) -> ST s String

  native trimToSize :: Mutable s (Vector e) -> ST s ()

  fromList :: [a] -> STMutable s (Vector a)
  fromList xs = do
      jlist <- Vector.new xs.length
      jlist.addAllFromList xs
      return jlist

instance Serializable (Vector e)

{--
 An object that maps keys to values.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Map.html JavaDoc'
-}
data Map k v = native java.util.Map where

  native clear :: Mutable s (Map k v) -> ST s ()

  native containsKey :: Mutable s (Map k v) -> k -> ST s Bool

  native containsValue :: Mutable s (Map k v) -> v -> ST s Bool

  native entrySet :: Mutable s (Map k v) -> STMutable s (Set (Mutable s (MapEntry k v)))

  native equals :: Mutable s (Map k v) -> Mutable s (Map k v) -> ST s Bool

  native get :: Mutable s (Map k v) -> k -> ST s (Maybe v)

  native hashCode :: Mutable s (Map k v) -> ST s Int

  native isEmpty :: Mutable s (Map k v) -> ST s Bool

  native keySet :: Mutable s (Map k v) -> STMutable s (Set k)

  native put :: Mutable s (Map k v) -> k -> v -> ST s (Maybe v)

  native putAll :: Mutable s (Map k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (Map k v) -> k -> ST s (Maybe v)

  native size :: Mutable s (Map k v) -> ST s Int

  native values :: Mutable s (Map k v) -> STMutable s (Collection v)

  addAllFromList :: Mutable s (Map k v) -> [(k, v)] -> ST s ()
  addAllFromList jmap [] = return ()
  addAllFromList jmap ((k, v): xs) = jmap.put k v >> addAllFromList jmap xs

  toList :: Mutable s (Map k v) -> ST s [(k, v)]
  toList jmap = do
        isEmpty <- jmap.isEmpty
        if isEmpty
          then return []
          else do
            entSet <- jmap.entrySet
            kvs <- entSet.iterator >>= Iterator.toList
            mapM (\ent -> ent.getKey >>= (\k -> ent.getValue >>= (\v -> return (k, v)))) kvs

{--
 A map entry (key-value pair).
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Map.Entry.html JavaDoc'
-}
data MapEntry k v = native java.util.Map.Entry where

  native equals :: Mutable s (MapEntry k v) -> Mutable s (MapEntry k v) -> ST s Bool

  native getKey :: Mutable s (MapEntry k v) -> ST s k

  native getValue :: Mutable s (MapEntry k v) -> ST s v

  native hashCode :: Mutable s (MapEntry k v) -> ST s Int

  native setValue :: Mutable s (MapEntry k v) -> v -> ST s v

{--
 This class provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/AbstractMap.html JavaDoc'
-}
data AbstractMap k v = native java.util.AbstractMap where

  native clear :: Mutable s (AbstractMap k v) -> ST s ()

  native containsKey :: Mutable s (AbstractMap k v) -> k -> ST s Bool

  native containsValue :: Mutable s (AbstractMap k v) -> v -> ST s Bool

  native entrySet :: Mutable s (AbstractMap k v) -> STMutable s (Set (Mutable s (MapEntry k v)))

  native equals :: Mutable s (AbstractMap k v) -> Mutable s (AbstractMap k v) -> ST s Bool

  native get :: Mutable s (AbstractMap k v) -> k -> ST s (Maybe v)

  native hashCode :: Mutable s (AbstractMap k v) -> ST s Int

  native isEmpty :: Mutable s (AbstractMap k v) -> ST s Bool

  native keySet :: Mutable s (AbstractMap k v) -> STMutable s (Set k)

  native put :: Mutable s (AbstractMap k v) -> k -> v -> ST s (Maybe v)

  native putAll :: Mutable s (AbstractMap k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (AbstractMap k v) -> k -> ST s v

  native size :: Mutable s (AbstractMap k v) -> ST s Int

  native toString :: Mutable s (AbstractMap k v) -> ST s String

  native values :: Mutable s (AbstractMap k v) -> STMutable s (Collection v)


{--
 The Formattable interface must be implemented by any class that needs to perform custom formatting using the 's'
 conversion specifier of 'https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html Formatter'.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html JavaDoc'
-}
data Formattable = native java.util.Formattable where

  native formatTo :: Mutable s Formattable -> Mutable s Formatter -> Int -> Int -> Int -> ST s ()


{--
 A 'https://docs.oracle.com/javase/7/docs/api/java/util/Map.html Map' that further provides a total ordering on its keys.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/SortedMap.html JavaDoc'
-}
data SortedMap k v = native java.util.SortedMap where

  native comparator :: Mutable s (SortedMap k v) -> ST s (Comparator (≥k))

  native entrySet :: Mutable s (SortedMap k v) -> STMutable s (Set (MapEntry k v))

  native firstKey :: Mutable s (SortedMap k v) -> ST s k

  native headMap :: Mutable s (SortedMap k v) -> k -> STMutable s (SortedMap k v)

  native keySet :: Mutable s (SortedMap k v) -> STMutable s (Set k)

  native lastKey :: Mutable s (SortedMap k v) -> ST s k

  native subMap :: Mutable s (SortedMap k v) -> k -> k -> STMutable s (SortedMap k v)

  native tailMap :: Mutable s (SortedMap k v) -> k -> STMutable s (SortedMap k v)

  native values :: Mutable s (SortedMap k v) -> STMutable s (Collection v)


{--
 Marker interface used by List implementations to indicate that they support fast (generally constant time) random access.

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/RandomAccess.html JavaDoc'
-}
data RandomAccess = native java.util.RandomAccess

{--
 An iterator over a collection.
 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html JavaDoc'
-}
data Iterator e = native java.util.Iterator where

  native hasNext :: Mutable s (Iterator e) -> ST s Bool

  native next :: Mutable s (Iterator e) -> ST s e

  native remove :: Mutable s (Iterator e) -> ST s ()

  --- Fold over a java 'Iterator'
  --- Unlike a fold over the result of 'Iterator.toList', this doesn't need extra memory.
  fold :: (c -> a -> c) -> c -> Mutable s (Iterator a) -> ST s c
  fold f acc it = go acc
    where 
        go !acc = do
            more ← it.hasNext
            if more
            then it.next >>= go . f acc
            else pure acc

  {-- 
      Converts the elements of this 'Iterator' to a Frege list.
      Unfortunately, because the 'Iterator' is mutable, 
      the list is not constructed lazily, but at once.
      And since it comes out in the wrong order, it must finally be reversed.

      This can be deadly when the 'Iterator' has large amounts of data, 
      as there must be _2n_ list nodes created, at least temporarily.

      If all you want to do is to reduce (i.e. 'fold') the resulting list,
      consider 'Iterator.fold', which doesn't expend any additional memory. 
  -}
  toList :: Mutable s (Iterator e) -> ST s [e]
  toList itr = reverse <$> toList' []
    where
      toList' acc = do
        hasNext <- itr.hasNext
        if hasNext
          then itr.next >>= (\item -> toList' (item : acc))
          else return acc

{--
 An ordered collection (also known as a sequence).

 More: 'https://docs.oracle.com/javase/7/docs/api/java/util/List.html JavaDoc'
-}
data List e = native java.util.List{e} where

  native add :: Mutable s (List e) -> e -> ST s Bool
              | Mutable s (List e) -> Int -> e -> ST s ()

  native addAll :: Mutable s (List e) -> Int -> Mutable s (Collection e) -> ST s Bool
                 | Mutable s (List e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (List e) -> ST s ()

  native contains :: Mutable s (List e) -> e -> ST s Bool

  native containsAll :: Mutable s (List e) -> Mutable s (Collection e) -> ST s Bool

  native equals :: Mutable s (List e) -> Mutable s (List e) -> ST s Bool

  native get :: Mutable s (List e) -> Int -> ST s (Maybe e)

  native hashCode :: Mutable s (List e) -> ST s Int

  native indexOf :: Mutable s (List e) -> e -> ST s Int

  native isEmpty :: Mutable s (List e) -> ST s Bool

  native iterator :: Mutable s (List e) -> STMutable s (Iterator e)

  native lastIndexOf :: Mutable s (List e) -> e -> ST s Int

  native listIterator :: Mutable s (List e) -> STMutable s (ListIterator e)
                       | Mutable s (List e) -> Int -> STMutable s (ListIterator e)

  native remove :: Mutable s (List e) -> e -> ST s Bool
                 | Mutable s (List e) -> Int -> ST s e

  native removeAll :: Mutable s (List e) -> Mutable s (Collection e) -> ST s Bool

  native retainAll :: Mutable s (List e) -> Mutable s (Collection e) -> ST s Bool

  native set :: Mutable s (List e) -> Int -> e -> ST s e

  native size :: Mutable s (List e) -> ST s Int

  native subList :: Mutable s (List e) -> Int -> Int -> STMutable s (List e)

  native toArray :: Mutable s (List e) -> STMutable s (JArray Object)
                  | Mutable s (List e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

{--
  Builder is used to build instances of Locale from values configured by the setters.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Locale.Builder.html JavaDoc'
-}
data LocaleBuilder = native java.util.Locale.Builder where

  native new :: () -> STMutable s LocaleBuilder

  native addUnicodeLocaleAttribute :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native build :: Mutable s LocaleBuilder -> ST s Locale

  native clear :: Mutable s LocaleBuilder -> STMutable s LocaleBuilder

  native clearExtensions :: Mutable s LocaleBuilder -> STMutable s LocaleBuilder

  native removeUnicodeLocaleAttribute :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native setExtension :: Mutable s LocaleBuilder -> Char -> String -> STMutable s LocaleBuilder

  native setLanguage :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native setLanguageTag :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native setLocale :: Mutable s LocaleBuilder -> Locale -> STMutable s LocaleBuilder

  native setRegion :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native setScript :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

  native setUnicodeLocaleKeyword :: Mutable s LocaleBuilder -> String -> String -> STMutable s LocaleBuilder

  native setVariant :: Mutable s LocaleBuilder -> String -> STMutable s LocaleBuilder

{--
  A collection that contains no duplicate elements.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Set.html JavaDoc'
-}
data Set e = native java.util.Set where

  native add :: Mutable s (Set e) -> e -> ST s Bool

  native addAll :: Mutable s (Set e) -> Mutable s (Collection e) -> ST s Bool

  native clear :: Mutable s (Set e) -> ST s ()

  native contains :: Mutable s (Set e) -> e -> ST s Bool

  native containsAll :: Mutable s (Set e) -> Mutable s (Collection e) -> ST s Bool

  native equals :: Mutable s (Set e) -> Mutable s (Set e) -> ST s Bool

  native hashCode :: Mutable s (Set e) -> ST s Int

  native isEmpty :: Mutable s (Set e) -> ST s Bool

  native iterator :: Mutable s (Set e) -> STMutable s (Iterator e)

  native remove :: Mutable s (Set e) -> e -> ST s Bool

  native removeAll :: Mutable s (Set e) -> Mutable s (Collection e) -> ST s Bool

  native retainAll :: Mutable s (Set e) -> Mutable s (Collection e) -> ST s Bool

  native size :: Mutable s (Set e) -> ST s Int

  native toArray :: Mutable s (Set e) -> STMutable s (JArray Object)
                  | Mutable s (Set e) -> Mutable s (JArray Object) -> STMutable s (JArray Object)

  toList :: Mutable s (Set e) -> ST s [e]
  toList set = set.iterator >>= Iterator.toList

{--
  This class contains various methods for manipulating arrays (such as sorting and searching).

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html Javadoc'
-}
data Arrays = pure native java.util.Arrays where

  native asList java.util.Arrays.asList{t} :: Mutable s (JArray t) -> STMutable s (List t)

  native binarySearch java.util.Arrays.binarySearch{t} :: Mutable s (JArray Char) -> Int -> Int -> Char -> ST s Int
                                                     | Mutable s (JArray Char) -> Char -> ST s Int
                                                     | Mutable s (JArray Byte) -> Byte -> ST s Int
                                                     | Mutable s (JArray Byte) -> Int -> Int -> Byte -> ST s Int
                                                     | Mutable s (JArray Double) -> Double -> ST s Int
                                                     | Mutable s (JArray Int) -> Int -> ST s Int
                                                     | Mutable s (JArray Int) -> Int -> Int -> Int -> ST s Int
                                                     | Mutable s (JArray Long) -> Int -> Int -> Long -> ST s Int
                                                     | Mutable s (JArray Short) -> Short -> ST s Int
                                                     | Mutable s (JArray Short) -> Int -> Int -> Short -> ST s Int
                                                     | Mutable s (JArray Long) -> Long -> ST s Int
                                                     | Mutable s (JArray Float) -> Int -> Int -> Float -> ST s Int
                                                     | Mutable s (JArray t) -> Int -> Int -> t -> Comparator (≥t) -> ST s Int
                                                     | Mutable s (JArray t) -> Int -> Int -> t -> ST s Int
                                                     | Mutable s (JArray t) -> t -> Comparator (≥t) -> ST s Int
                                                     | Mutable s (JArray Double) -> Int -> Int -> Double -> ST s Int
                                                     | Mutable s (JArray t) -> t -> ST s Int
                                                     | Mutable s (JArray Float) -> Float -> ST s Int

  native copyOf java.util.Arrays.copyOf{t} :: Mutable s (JArray Int) -> Int -> STMutable s (JArray Int)
                                         | Mutable s (JArray Short) -> Int -> STMutable s (JArray Short)
                                         | Mutable s (JArray Long) -> Int -> STMutable s (JArray Long)
                                         | Mutable s (JArray Byte) -> Int -> STMutable s (JArray Byte)
                                         -- Mutable s (JArray t) -> Int -> Class (JArray t) -> STMutable s (JArray Object)
                                         | Mutable s (JArray t) -> Int -> STMutable s (JArray Object)
                                         | Mutable s (JArray Bool) -> Int -> STMutable s (JArray Bool)
                                         | Mutable s (JArray Double) -> Int -> STMutable s (JArray Double)
                                         | Mutable s (JArray Float) -> Int -> STMutable s (JArray Float)
                                         | Mutable s (JArray Char) -> Int -> STMutable s (JArray Char)

  native copyOfRange java.util.Arrays.copyOfRange{t} :: Mutable s (JArray Bool) -> Int -> Int -> STMutable s (JArray Bool)
                                                   | Mutable s (JArray Double) -> Int -> Int -> STMutable s (JArray Double)
                                                   | Mutable s (JArray Long) -> Int -> Int -> STMutable s (JArray Long)
                                                   | Mutable s (JArray Float) -> Int -> Int -> STMutable s (JArray Float)
                                                   | Mutable s (JArray Char) -> Int -> Int -> STMutable s (JArray Char)
                                                   | Mutable s (JArray t) -> Int -> Int -> STMutable s (JArray t)
                                                   -- Mutable s (JArray t) -> Int -> Int -> Class (JArray t) -> STMutable s (JArray t)
                                                   | Mutable s (JArray Byte) -> Int -> Int -> STMutable s (JArray Byte)
                                                   | Mutable s (JArray Short) -> Int -> Int -> STMutable s (JArray Short)
                                                   | Mutable s (JArray Int) -> Int -> Int -> STMutable s (JArray Int)

  native deepEquals java.util.Arrays.deepEquals{t} :: Mutable s (JArray t) -> Mutable s (JArray t) -> ST s Bool

  native deepHashCode java.util.Arrays.deepHashCode{t} :: Mutable s (JArray t) -> ST s Int

  native deepToString java.util.Arrays.deepToString{t} :: Mutable s (JArray t) -> ST s String

  native equals java.util.Arrays.equals{t} :: Mutable s (JArray Char) -> Mutable s (JArray Char) -> ST s Bool
                                         | Mutable s (JArray Short) -> Mutable s (JArray Short) -> ST s Bool
                                         | Mutable s (JArray Int) -> Mutable s (JArray Int) -> ST s Bool
                                         | Mutable s (JArray t) -> Mutable s (JArray t) -> ST s Bool
                                         | Mutable s (JArray Float) -> Mutable s (JArray Float) -> ST s Bool
                                         | Mutable s (JArray Double) -> Mutable s (JArray Double) -> ST s Bool
                                         | Mutable s (JArray Bool) -> Mutable s (JArray Bool) -> ST s Bool
                                         | Mutable s (JArray Byte) -> Mutable s (JArray Byte) -> ST s Bool
                                         | Mutable s (JArray Long) -> Mutable s (JArray Long) -> ST s Bool

  native fill java.util.Arrays.fill{t} :: Mutable s (JArray Short) -> Int -> Int -> Short -> ST s ()
                                     | Mutable s (JArray Int) -> Int -> ST s ()
                                     | Mutable s (JArray Int) -> Int -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Short) -> Short -> ST s ()
                                     | Mutable s (JArray Double) -> Double -> ST s ()
                                     | Mutable s (JArray Double) -> Int -> Int -> Double -> ST s ()
                                     | Mutable s (JArray Float) -> Float -> ST s ()
                                     | Mutable s (JArray Float) -> Int -> Int -> Float -> ST s ()
                                     | Mutable s (JArray t) -> t -> ST s ()
                                     | Mutable s (JArray t) -> Int -> Int -> t -> ST s ()
                                     | Mutable s (JArray Char) -> Char -> ST s ()
                                     | Mutable s (JArray Char) -> Int -> Int -> Char -> ST s ()
                                     | Mutable s (JArray Byte) -> Byte -> ST s ()
                                     | Mutable s (JArray Byte) -> Int -> Int -> Byte -> ST s ()
                                     | Mutable s (JArray Bool) -> Bool -> ST s ()
                                     | Mutable s (JArray Bool) -> Int -> Int -> Bool -> ST s ()
                                     | Mutable s (JArray Long) -> Long -> ST s ()
                                     | Mutable s (JArray Long) -> Int -> Int -> Long -> ST s ()

  native hashCode java.util.Arrays.hashCode{t} :: Mutable s (JArray Byte) -> ST s Int
                                             | Mutable s (JArray Bool) -> ST s Int
                                             | Mutable s (JArray Float) -> ST s Int
                                             | Mutable s (JArray Double) -> ST s Int
                                             | Mutable s (JArray t) -> ST s Int
                                             | Mutable s (JArray Long) -> ST s Int
                                             | Mutable s (JArray Int) -> ST s Int
                                             | Mutable s (JArray Short) -> ST s Int
                                             | Mutable s (JArray Char) -> ST s Int

  native sort java.util.Arrays.sort{t} :: Mutable s (JArray t) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Float) -> ST s ()
                                     | Mutable s (JArray Double) -> ST s ()
                                     | Mutable s (JArray Double) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Float) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray t) -> ST s ()
                                     | Mutable s (JArray Short) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Short) -> ST s ()
                                     | Mutable s (JArray Long) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Long) -> ST s ()
                                     | Mutable s (JArray Byte) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Byte) -> ST s ()
                                     | Mutable s (JArray Char) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray Char) -> ST s ()
                                     | Mutable s (JArray Int) -> Int -> Int -> ST s ()
                                     | Mutable s (JArray t) -> Int -> Int -> Comparator t -> ST s ()
                                     | Mutable s (JArray t) -> Comparator t -> ST s ()
                                     | Mutable s (JArray Int) -> ST s ()

  native toString java.util.Arrays.toString{t} :: Mutable s (JArray Bool) -> ST s String
                                             | Mutable s (JArray Float) -> ST s String
                                             | Mutable s (JArray Double) -> ST s String
                                             | Mutable s (JArray t) -> ST s String
                                             | Mutable s (JArray Long) -> ST s String
                                             | Mutable s (JArray Int) -> ST s String
                                             | Mutable s (JArray Short) -> ST s String
                                             | Mutable s (JArray Char) -> ST s String
                                             | Mutable s (JArray Byte) -> ST s String
{--
  This class implements a vector of bits that grows as needed.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html JavaDoc'
-}
data BitSet = native java.util.BitSet where

  native new :: Int -> STMutable s BitSet
              | () -> STMutable s BitSet

  native and :: Mutable s BitSet -> Mutable s BitSet -> ST s ()

  native andNot :: Mutable s BitSet -> Mutable s BitSet -> ST s ()

  native cardinality :: Mutable s BitSet -> ST s Int

  native clear :: Mutable s BitSet -> Int -> ST s ()
                | Mutable s BitSet -> Int -> Int -> ST s ()
                | Mutable s BitSet -> ST s ()

  native clone :: Mutable s BitSet -> ST s Object

  native equals :: Mutable s BitSet -> Object -> ST s Bool

  native flip :: Mutable s BitSet -> Int -> Int -> ST s ()
               | Mutable s BitSet -> Int -> ST s ()

  native get :: Mutable s BitSet -> Int -> Int -> STMutable s BitSet
              | Mutable s BitSet -> Int -> ST s Bool

  native hashCode :: Mutable s BitSet -> ST s Int

  native intersects :: Mutable s BitSet -> Mutable s BitSet -> ST s Bool

  native isEmpty :: Mutable s BitSet -> ST s Bool

  native length :: Mutable s BitSet -> ST s Int

  native nextClearBit :: Mutable s BitSet -> Int -> ST s Int

  native nextSetBit :: Mutable s BitSet -> Int -> ST s Int

  native or :: Mutable s BitSet -> Mutable s BitSet -> ST s ()

  native previousClearBit :: Mutable s BitSet -> Int -> ST s Int

  native previousSetBit :: Mutable s BitSet -> Int -> ST s Int

  native set :: Mutable s BitSet -> Int -> ST s ()
              | Mutable s BitSet -> Int -> Bool -> ST s ()
              | Mutable s BitSet -> Int -> Int -> ST s ()
              | Mutable s BitSet -> Int -> Int -> Bool -> ST s ()

  native size :: Mutable s BitSet -> ST s Int

  native toByteArray :: Mutable s BitSet -> STMutable s (JArray Byte)

  native toLongArray :: Mutable s BitSet -> STMutable s (JArray Long)

  native toString :: Mutable s BitSet -> ST s String

  native valueOf java.util.BitSet.valueOf :: Mutable s ByteBuffer -> STMutable s BitSet
                                           | Mutable s (JArray Long) -> STMutable s BitSet
                                           | Mutable s LongBuffer -> STMutable s BitSet
                                           | Mutable s (JArray Byte) -> STMutable s BitSet

  native xor :: Mutable s BitSet -> Mutable s BitSet -> ST s ()

instance Serializable BitSet

{--
  The class Date represents a specific instant in time, with millisecond precision.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Date.html JavaDoc'
  
  Several methods are deprecated meanwhile. They are simply commented out here
-}
data Date = native java.util.Date where

  native new :: Long -> STMutable s Date
              -- Int -> Int -> Int -> Int -> Int -> Int -> STMutable s Date
              -- Int -> Int -> Int -> Int -> Int -> STMutable s Date
              | () -> IO (MutableIO Date)
              -- String -> STMutable s Date
              -- Int -> Int -> Int -> STMutable s Date

  native after :: Mutable s Date -> Mutable s Date -> ST s Bool

  native before :: Mutable s Date -> Mutable s Date -> ST s Bool

  native clone :: Mutable s Date -> ST s Object

  native compareTo :: Mutable s Date -> Mutable s Date -> ST s Int

  native equals :: Mutable s Date -> Object -> ST s Bool

  -- native getDate :: Mutable s Date -> ST s Int

  -- native getDay :: Mutable s Date -> ST s Int

  -- native getHours :: Mutable s Date -> ST s Int

  -- native getMinutes :: Mutable s Date -> ST s Int

  -- native getMonth :: Mutable s Date -> ST s Int

  -- native getSeconds :: Mutable s Date -> ST s Int

  native getTime :: Mutable s Date -> ST s Long

  -- native getTimezoneOffset :: Mutable s Date -> ST s Int

  -- native getYear :: Mutable s Date -> ST s Int

  native hashCode :: Mutable s Date -> ST s Int

  pure native parse java.util.Date.parse :: String -> Long

  -- native setDate :: Mutable s Date -> Int -> ST s ()

  -- native setHours :: Mutable s Date -> Int -> ST s ()

  -- native setMinutes :: Mutable s Date -> Int -> ST s ()

  -- native setMonth :: Mutable s Date -> Int -> ST s ()

  -- native setSeconds :: Mutable s Date -> Int -> ST s ()

  native setTime :: Mutable s Date -> Long -> ST s ()

  -- native setYear :: Mutable s Date -> Int -> ST s ()

  -- native toGMTString :: Mutable s Date -> ST s String

  -- native toLocaleString :: Mutable s Date -> ST s String

  native toString :: Mutable s Date -> ST s String

  pure native uTC java.util.Date.UTC :: Int -> Int -> Int -> Int -> Int -> Int -> Long

instance Serializable Date

{--
  TimeZone represents a time zone offset, and also figures out daylight savings.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html JavaDoc'
-}
data TimeZone = pure native java.util.TimeZone where

  pure native short java.util.TimeZone.SHORT :: Int
  pure native long java.util.TimeZone.LONG :: Int

  pure native clone :: TimeZone -> Object

  native getAvailableIDs java.util.TimeZone.getAvailableIDs :: () -> STMutable s (JArray String)
                                                             | Int -> STMutable s (JArray String)

  pure native getDSTSavings :: TimeZone -> Int

  native getDefault java.util.TimeZone.getDefault :: () -> ST s TimeZone

  pure native getDisplayName :: TimeZone -> Bool -> Int -> Locale -> String
                              | TimeZone -> String
                              | TimeZone -> Bool -> Int -> String
                              | TimeZone -> Locale -> String

  pure native getID :: TimeZone -> String

  pure native getOffset :: TimeZone -> Int -> Int -> Int -> Int -> Int -> Int -> Int
                         | TimeZone -> Long -> Int

  pure native getRawOffset :: TimeZone -> Int

  pure native getTimeZone java.util.TimeZone.getTimeZone :: String -> TimeZone

  pure native hasSameRules :: TimeZone -> TimeZone -> Bool

  native inDaylightTime :: TimeZone -> Mutable s Date -> ST s Bool

  pure native observesDaylightTime :: TimeZone -> Bool

  native setDefault java.util.TimeZone.setDefault :: TimeZone -> ST s ()

  native setID :: TimeZone -> String -> ST s ()

  native setRawOffset :: TimeZone -> Int -> ST s ()

  pure native useDaylightTime :: TimeZone -> Bool

instance Serializable TimeZone

{--
  The Calendar class is an abstract class that provides methods for converting between a specific instant in time and
  a set of 'https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#fields calendar fields' such as YEAR, MONTH,
  DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html JavaDoc'
-}
data Calendar = native java.util.Calendar where

  pure native era java.util.Calendar.ERA :: Int
  pure native year java.util.Calendar.YEAR :: Int
  pure native month java.util.Calendar.MONTH :: Int
  pure native week_of_year java.util.Calendar.WEEK_OF_YEAR :: Int
  pure native week_of_month java.util.Calendar.WEEK_OF_MONTH :: Int
  pure native date java.util.Calendar.DATE :: Int
  pure native day_of_month java.util.Calendar.DAY_OF_MONTH :: Int
  pure native day_of_year java.util.Calendar.DAY_OF_YEAR :: Int
  pure native day_of_week java.util.Calendar.DAY_OF_WEEK :: Int
  pure native day_of_week_in_month java.util.Calendar.DAY_OF_WEEK_IN_MONTH :: Int
  pure native am_pm java.util.Calendar.AM_PM :: Int
  pure native hour java.util.Calendar.HOUR :: Int
  pure native hour_of_day java.util.Calendar.HOUR_OF_DAY :: Int
  pure native minute java.util.Calendar.MINUTE :: Int
  pure native second java.util.Calendar.SECOND :: Int
  pure native millisecond java.util.Calendar.MILLISECOND :: Int
  pure native zone_offset java.util.Calendar.ZONE_OFFSET :: Int
  pure native dst_offset java.util.Calendar.DST_OFFSET :: Int
  pure native field_count java.util.Calendar.FIELD_COUNT :: Int
  pure native sunday java.util.Calendar.SUNDAY :: Int
  pure native monday java.util.Calendar.MONDAY :: Int
  pure native tuesday java.util.Calendar.TUESDAY :: Int
  pure native wednesday java.util.Calendar.WEDNESDAY :: Int
  pure native thursday java.util.Calendar.THURSDAY :: Int
  pure native friday java.util.Calendar.FRIDAY :: Int
  pure native saturday java.util.Calendar.SATURDAY :: Int
  pure native january java.util.Calendar.JANUARY :: Int
  pure native february java.util.Calendar.FEBRUARY :: Int
  pure native march java.util.Calendar.MARCH :: Int
  pure native april java.util.Calendar.APRIL :: Int
  pure native may java.util.Calendar.MAY :: Int
  pure native june java.util.Calendar.JUNE :: Int
  pure native july java.util.Calendar.JULY :: Int
  pure native august java.util.Calendar.AUGUST :: Int
  pure native september java.util.Calendar.SEPTEMBER :: Int
  pure native october java.util.Calendar.OCTOBER :: Int
  pure native november java.util.Calendar.NOVEMBER :: Int
  pure native december java.util.Calendar.DECEMBER :: Int
  pure native undecimber java.util.Calendar.UNDECIMBER :: Int
  pure native am java.util.Calendar.AM :: Int
  pure native pm java.util.Calendar.PM :: Int
  pure native all_styles java.util.Calendar.ALL_STYLES :: Int
  pure native short java.util.Calendar.SHORT :: Int
  pure native long java.util.Calendar.LONG :: Int

  native add :: Mutable s Calendar -> Int -> Int -> ST s ()

  native after :: Mutable s Calendar -> Object -> ST s Bool

  native before :: Mutable s Calendar -> Object -> ST s Bool

  native clear :: Mutable s Calendar -> ST s ()
                | Mutable s Calendar -> Int -> ST s ()

  native clone :: Mutable s Calendar -> ST s Object

  native compareTo :: Mutable s Calendar -> Mutable s Calendar -> ST s Int

  native equals :: Mutable s Calendar -> Object -> ST s Bool

  native get :: Mutable s Calendar -> Int -> ST s Int

  native getActualMaximum :: Mutable s Calendar -> Int -> ST s Int

  native getActualMinimum :: Mutable s Calendar -> Int -> ST s Int

  native getAvailableLocales java.util.Calendar.getAvailableLocales :: () -> STMutable s (JArray Locale)

  native getDisplayName :: Mutable s Calendar -> Int -> Int -> Locale -> ST s String

  native getDisplayNames :: Mutable s Calendar -> Int -> Int -> Locale -> STMutable s (Map String Int)

  native getFirstDayOfWeek :: Mutable s Calendar -> ST s Int

  native getGreatestMinimum :: Mutable s Calendar -> Int -> ST s Int

  native getInstance java.util.Calendar.getInstance :: () -> STMutable s Calendar
                                                     | TimeZone -> STMutable s Calendar
                                                     | Locale -> STMutable s Calendar
                                                     | TimeZone -> Locale -> STMutable s Calendar

  native getLeastMaximum :: Mutable s Calendar -> Int -> ST s Int

  native getMaximum :: Mutable s Calendar -> Int -> ST s Int

  native getMinimalDaysInFirstWeek :: Mutable s Calendar -> ST s Int

  native getMinimum :: Mutable s Calendar -> Int -> ST s Int

  native getTime :: Mutable s Calendar -> STMutable s Date

  native getTimeInMillis :: Mutable s Calendar -> ST s Long

  native getTimeZone :: Mutable s Calendar -> ST s TimeZone

  native getWeekYear :: Mutable s Calendar -> ST s Int

  native getWeeksInWeekYear :: Mutable s Calendar -> ST s Int

  native hashCode :: Mutable s Calendar -> ST s Int

  native isLenient :: Mutable s Calendar -> ST s Bool

  native isSet :: Mutable s Calendar -> Int -> ST s Bool

  native isWeekDateSupported :: Mutable s Calendar -> ST s Bool

  native roll :: Mutable s Calendar -> Int -> Bool -> ST s ()
               | Mutable s Calendar -> Int -> Int -> ST s ()

  native set :: Mutable s Calendar -> Int -> Int -> Int -> Int -> Int -> ST s ()
              | Mutable s Calendar -> Int -> Int -> ST s ()
              | Mutable s Calendar -> Int -> Int -> Int -> ST s ()
              | Mutable s Calendar -> Int -> Int -> Int -> Int -> Int -> Int -> ST s ()

  native setFirstDayOfWeek :: Mutable s Calendar -> Int -> ST s ()

  native setLenient :: Mutable s Calendar -> Bool -> ST s ()

  native setMinimalDaysInFirstWeek :: Mutable s Calendar -> Int -> ST s ()

  native setTime :: Mutable s Calendar -> Mutable s Date -> ST s ()

  native setTimeInMillis :: Mutable s Calendar -> Long -> ST s ()

  native setTimeZone :: Mutable s Calendar -> TimeZone -> ST s ()

  native setWeekDate :: Mutable s Calendar -> Int -> Int -> Int -> ST s ()

  native toString :: Mutable s Calendar -> ST s String

instance Serializable Calendar

{--
  GregorianCalendar is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html JavaDoc'
-}
data GregorianCalendar = native java.util.GregorianCalendar where

  pure native bc java.util.GregorianCalendar.BC :: Int
  pure native ad java.util.GregorianCalendar.AD :: Int

  native new :: Int -> Int -> Int -> STMutable s GregorianCalendar
              | Int -> Int -> Int -> Int -> Int -> STMutable s GregorianCalendar
              | Int -> Int -> Int -> Int -> Int -> Int -> STMutable s GregorianCalendar
              | () -> STMutable s GregorianCalendar
              | TimeZone -> STMutable s GregorianCalendar
              | Locale -> STMutable s GregorianCalendar
              | TimeZone -> Locale -> STMutable s GregorianCalendar

  native add :: Mutable s GregorianCalendar -> Int -> Int -> ST s ()

  native clone :: Mutable s GregorianCalendar -> ST s Object

  native equals :: Mutable s GregorianCalendar -> Object -> ST s Bool

  native getActualMaximum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getActualMinimum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getGreatestMinimum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getGregorianChange :: Mutable s GregorianCalendar -> STMutable s Date

  native getLeastMaximum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getMaximum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getMinimum :: Mutable s GregorianCalendar -> Int -> ST s Int

  native getTimeZone :: Mutable s GregorianCalendar -> ST s TimeZone

  native getWeekYear :: Mutable s GregorianCalendar -> ST s Int

  native getWeeksInWeekYear :: Mutable s GregorianCalendar -> ST s Int

  native hashCode :: Mutable s GregorianCalendar -> ST s Int

  native isLeapYear :: Mutable s GregorianCalendar -> Int -> ST s Bool

  native isWeekDateSupported :: Mutable s GregorianCalendar -> ST s Bool

  native roll :: Mutable s GregorianCalendar -> Int -> Int -> ST s ()
               | Mutable s GregorianCalendar -> Int -> Bool -> ST s ()

  native setGregorianChange :: Mutable s GregorianCalendar -> Mutable s Date -> ST s ()

  native setTimeZone :: Mutable s GregorianCalendar -> TimeZone -> ST s ()

  native setWeekDate :: Mutable s GregorianCalendar -> Int -> Int -> Int -> ST s ()

instance Serializable GregorianCalendar

{--
  This class consists exclusively of static methods that operate on or return collections.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html JavaDoc'
-}
data Collections = pure native java.util.Collections where

  native empty_set java.util.Collections.EMPTY_SET :: STMutable s (Set e)
  native empty_list java.util.Collections.EMPTY_LIST :: STMutable s (List e)
  native empty_map java.util.Collections.EMPTY_MAP :: STMutable s (Map k v)

  native addAll java.util.Collections.addAll{t} :: Mutable s (Collection t) -> Mutable s (JArray t) -> ST s Bool

  native asLifoQueue java.util.Collections.asLifoQueue{t} :: Mutable s (Deque t) -> STMutable s (Queue t)

  native binarySearch java.util.Collections.binarySearch{t} :: Mutable s (List (Comparable t)) -> t -> ST s Int
                                                          | Mutable s (List t) -> t -> Comparator t -> ST s Int

  native checkedCollection java.util.Collections.checkedCollection{e} :: Mutable s (Collection e) -> Class e -> STMutable s (Collection e)

  native checkedList java.util.Collections.checkedList{e} :: Mutable s (List e) -> Class e -> STMutable s (List e)

  native checkedMap java.util.Collections.checkedMap{k,v} :: Mutable s (Map k v) -> Class k -> Class v -> STMutable s (Map k v)

  native checkedSet java.util.Collections.checkedSet{e} :: Mutable s (Set e) -> Class e -> STMutable s (Set e)

  native checkedSortedMap java.util.Collections.checkedSortedMap{k,v} :: Mutable s (SortedMap k v) -> Class k -> Class v -> STMutable s (SortedMap k v)

  native checkedSortedSet java.util.Collections.checkedSortedSet{e} :: Mutable s (SortedSet e) -> Class e -> STMutable s (SortedSet e)

  native copy java.util.Collections.copy{t} :: Mutable s (List t) -> Mutable s (List t) -> ST s ()

  native disjoint java.util.Collections.disjoint :: Mutable s (Collection Object) -> Mutable s (Collection Object) -> ST s Bool

  native emptyEnumeration java.util.Collections.emptyEnumeration{t} :: () -> STMutable s (Enumeration t)

  native emptyIterator java.util.Collections.emptyIterator{t} :: () -> STMutable s (Iterator t)

  native emptyList java.util.Collections.emptyList{t} :: () -> STMutable s (List t)

  native emptyListIterator java.util.Collections.emptyListIterator{t} :: () -> STMutable s (ListIterator t)

  native emptyMap java.util.Collections.emptyMap{k,v} :: () -> STMutable s (Map k v)

  native emptySet java.util.Collections.emptySet{t} :: () -> STMutable s (Set t)

  native enumeration java.util.Collections.enumeration{t} :: Mutable s (Collection t) -> STMutable s (Enumeration t)

  native fill java.util.Collections.fill{t} :: Mutable s (List t) -> t -> ST s ()

  native frequency java.util.Collections.frequency :: Mutable s (Collection Object) -> Object -> ST s Int

  native indexOfSubList java.util.Collections.indexOfSubList :: Mutable s (List Object) -> Mutable s (List Object) -> ST s Int

  native lastIndexOfSubList java.util.Collections.lastIndexOfSubList :: Mutable s (List Object) -> Mutable s (List Object) -> ST s Int

  native list java.util.Collections.list{t} :: Mutable s (Enumeration t) -> STMutable s (ArrayList t)

--  native max java.util.Collections.max{} :: Mutable s (Collection t) -> ST s t
--                                         |  Mutable s (Collection t) -> Comparator t -> ST s t
--
--  native min java.util.Collections.min{} :: Mutable s (Collection t) -> Comparator t -> ST s t
--                                         |  Mutable s (Collection t) -> ST s t

  native nCopies java.util.Collections.nCopies{t} :: Int -> t -> STMutable s (List t)

  native newSetFromMap java.util.Collections.newSetFromMap{e} :: Mutable s (Map e Boolean) -> STMutable s (Set e)

  native replaceAll java.util.Collections.replaceAll{t} :: Mutable s (List t) -> t -> t -> ST s Bool

  native reverse java.util.Collections.reverse :: Mutable s (List Object) -> ST s ()

  native reverseOrder java.util.Collections.reverseOrder{t} :: () -> ST s (Comparator t)
                                                          | Comparator t -> ST s (Comparator t)

  native rotate java.util.Collections.rotate :: Mutable s (List Object) -> Int -> ST s ()

  native shuffle java.util.Collections.shuffle :: Mutable s (List Object) -> Mutable s Random -> ST s ()
                                                | Mutable s (List Object) -> ST s ()

  native singleton java.util.Collections.singleton{t} :: t -> STMutable s (Set t)

  native singletonList java.util.Collections.singletonList{t} :: t -> STMutable s (List t)

  native singletonMap java.util.Collections.singletonMap{k,v} :: k -> v -> STMutable s (Map k v)

  native sort java.util.Collections.sort{} :: {- Mutable s (List t) -> ST s ()
                                          | -} Mutable s (List t) -> Comparator t -> ST s ()

  native swap java.util.Collections.swap :: Mutable s (List Object) -> Int -> Int -> ST s ()

  native synchronizedCollection java.util.Collections.synchronizedCollection{t} :: Mutable s (Collection t) -> STMutable s (Collection t)

  native synchronizedList java.util.Collections.synchronizedList{t} :: Mutable s (List t) -> STMutable s (List t)

  native synchronizedMap java.util.Collections.synchronizedMap{k,v} :: Mutable s (Map k v) -> STMutable s (Map k v)

  native synchronizedSet java.util.Collections.synchronizedSet{t} :: Mutable s (Set t) -> STMutable s (Set t)

  native synchronizedSortedMap java.util.Collections.synchronizedSortedMap{k,v} :: Mutable s (SortedMap k v) -> STMutable s (SortedMap k v)

  native synchronizedSortedSet java.util.Collections.synchronizedSortedSet{t} :: Mutable s (SortedSet t) -> STMutable s (SortedSet t)

  native unmodifiableCollection java.util.Collections.unmodifiableCollection{t} :: Mutable s (Collection t) -> STMutable s (Collection t)

  native unmodifiableList java.util.Collections.unmodifiableList{t} :: Mutable s (List t) -> STMutable s (List t)

  native unmodifiableMap java.util.Collections.unmodifiableMap{k,v} :: Mutable s (Map k v) -> STMutable s (Map k v)

  native unmodifiableSet java.util.Collections.unmodifiableSet{t} :: Mutable s (Set t) -> STMutable s (Set t)

  native unmodifiableSortedMap java.util.Collections.unmodifiableSortedMap{k,v} :: Mutable s (SortedMap k v) -> STMutable s (SortedMap k v)

  native unmodifiableSortedSet java.util.Collections.unmodifiableSortedSet{t} :: Mutable s (SortedSet t) -> STMutable s (SortedSet t)

{--
  Represents a currency.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Currency.html JavaDoc'
-}
data Currency = pure native java.util.Currency where

  native getAvailableCurrencies java.util.Currency.getAvailableCurrencies :: () -> STMutable s (Set Currency)

  pure native getCurrencyCode :: Currency -> String

  pure native getDefaultFractionDigits :: Currency -> Int

  pure native getDisplayName :: Currency -> Locale -> String
                              | Currency -> String

  pure native getInstance java.util.Currency.getInstance :: Locale -> Currency
                                                          | String -> Currency

  pure native getNumericCode :: Currency -> Int

  pure native getSymbol :: Currency -> String
                         | Currency -> Locale -> String

  pure native toString :: Currency -> String

instance Serializable Currency

{--
  The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Dictionary.html JavaDoc'
-}
data Dictionary k v = native java.util.Dictionary where

  native elements :: Mutable s (Dictionary k v) -> STMutable s (Enumeration v)

  native get :: Mutable s (Dictionary k v) -> Object -> ST s v

  native isEmpty :: Mutable s (Dictionary k v) -> ST s Bool

  native keys :: Mutable s (Dictionary k v) -> STMutable s (Enumeration k)

  native put :: Mutable s (Dictionary k v) -> k -> v -> ST s v

  native remove :: Mutable s (Dictionary k v) -> Object -> ST s v

  native size :: Mutable s (Dictionary k v) -> ST s Int

{--
  This class implements a hash table, which maps keys to values.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Hashtable.html JavaDoc'
-}
data Hashtable k v = native java.util.Hashtable where

  native new :: () -> STMutable s (Hashtable k v)
              | Int -> STMutable s (Hashtable k v)
              | Int -> Float -> STMutable s (Hashtable k v)
              | Mutable s (Map k v) -> STMutable s (Hashtable k v)

  native clear :: Mutable s (Hashtable k v) -> ST s ()

  native clone :: Mutable s (Hashtable k v) -> ST s Object

  native contains :: Mutable s (Hashtable k v) -> Object -> ST s Bool

  native containsKey :: Mutable s (Hashtable k v) -> Object -> ST s Bool

  native containsValue :: Mutable s (Hashtable k v) -> Object -> ST s Bool

  native elements :: Mutable s (Hashtable k v) -> STMutable s (Enumeration v)

  native entrySet :: Mutable s (Hashtable k v) -> STMutable s (Set (MapEntry k v))

  native equals :: Mutable s (Hashtable k v) -> Object -> ST s Bool

  native get :: Mutable s (Hashtable k v) -> Object -> ST s v

  native hashCode :: Mutable s (Hashtable k v) -> ST s Int

  native isEmpty :: Mutable s (Hashtable k v) -> ST s Bool

  native keySet :: Mutable s (Hashtable k v) -> STMutable s (Set k)

  native keys :: Mutable s (Hashtable k v) -> STMutable s (Enumeration k)

  native put :: Mutable s (Hashtable k v) -> k -> v -> ST s v

  native putAll :: Mutable s (Hashtable k v) -> Mutable s (Map k v) -> ST s ()

  native remove :: Mutable s (Hashtable k v) -> Object -> ST s v

  native size :: Mutable s (Hashtable k v) -> ST s Int

  native toString :: Mutable s (Hashtable k v) -> ST s String

  native values :: Mutable s (Hashtable k v) -> STMutable s (Collection v)

instance Serializable (Hashtable k v)

{--
  The Properties class represents a persistent set of properties.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html JavaDoc'
-}
data Properties = native java.util.Properties where

  native new :: () -> STMutable s Properties
              | Mutable s Properties -> STMutable s Properties

  native getProperty :: Mutable s Properties -> String -> String -> ST s String
                      | Mutable s Properties -> String -> ST s String

  native list :: MutableIO Properties -> MutableIO PrintStream -> IO ()
               | MutableIO Properties -> MutableIO PrintWriter -> IO ()

  native load :: MutableIO Properties -> MutableIO Reader -> IO () throws IOException
               | MutableIO Properties -> MutableIO InputStream -> IO () throws IOException

  native loadFromXML :: MutableIO Properties -> MutableIO InputStream -> IO () throws InvalidPropertiesFormatException, IOException

  -- native propertyNames :: Mutable s Properties -> STMutable s (Enumeration a)

  -- warning: [deprecation] save(OutputStream,String) in Properties has been deprecated
  -- native save :: MutableIO Properties -> OutputStream -> String -> IO ()

  native setProperty :: Mutable s Properties -> String -> String -> ST s Object

  native store :: MutableIO Properties -> MutableIO Writer -> String -> IO () throws IOException
                | MutableIO Properties -> MutableIO OutputStream -> String -> IO () throws IOException

  native storeToXML :: MutableIO Properties -> MutableIO OutputStream -> String -> IO () throws IOException
                     | MutableIO Properties -> MutableIO OutputStream -> String -> String -> IO () throws IOException

  native stringPropertyNames :: Mutable s Properties -> STMutable s (Set String)

instance Serializable Properties

{--
  An abstract wrapper class for an EventListener class which associates a set of additional parameters with the listener.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/EventListenerProxy.html JavaDoc'
-}
data EventListenerProxy t = native java.util.EventListenerProxy where

  native getListener :: Mutable s (EventListenerProxy EventListener) -> STMutable s EventListener

{--
  The root class from which all event state objects shall be derived.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/EventObject.html JavaDoc'
-}
data EventObject = native java.util.EventObject where

  native new :: Object -> STMutable s EventObject

  native getSource :: Mutable s EventObject -> ST s Object

  native toString :: Mutable s EventObject -> ST s String

instance Serializable EventObject

{--
  FormattableFlags are passed to the
  'https://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html#formatTo(java.util.Formatter,%20int,%20int,%20int) Formattable.formatTo()'
  method and modify the output format for 'https://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html Formattables'.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/FormattableFlags.html JavaDoc'
-}
data FormattableFlags = pure native java.util.FormattableFlags where

  pure native left_justify java.util.FormattableFlags.LEFT_JUSTIFY :: Int
  pure native uppercase java.util.FormattableFlags.UPPERCASE :: Int
  pure native alternate java.util.FormattableFlags.ALTERNATE :: Int

{--
  This class consists of static utility methods for operating on objects.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Objects.html JavaDoc'
-}
data Objects = pure native java.util.Objects where

  pure native compare java.util.Objects.compare{t} :: t -> t -> Comparator t -> Int

  pure native deepEquals java.util.Objects.deepEquals :: Object -> Object -> Bool

  pure native equals java.util.Objects.equals :: Object -> Object -> Bool

  native hash java.util.Objects.hash :: Mutable s (JArray Object) -> ST s Int

  pure native hashCode java.util.Objects.hashCode :: Object -> Int

  pure native requireNonNull java.util.Objects.requireNonNull{t} :: t -> t
                                                               | t -> String -> t

  pure native toString java.util.Objects.toString :: Object -> String
                                                   | Object -> String -> String

{--
  This class is for property permissions.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/PropertyPermission.html JavaDoc'
-}
data PropertyPermission = pure native java.util.PropertyPermission where

  native new :: String -> String -> ST s PropertyPermission

  pure native equals :: PropertyPermission -> Object -> Bool

  pure native getActions :: PropertyPermission -> String

  pure native hashCode :: PropertyPermission -> Int

  pure native implies :: PropertyPermission -> Permission -> Bool

  native newPermissionCollection :: PropertyPermission -> STMutable s PermissionCollection

instance Serializable PropertyPermission

{--
  ListResourceBundle is an abstract subclass of ResourceBundle that manages resources for a locale in a convenient and easy to use list.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ListResourceBundle.html JavaDoc'
-}
data ListResourceBundle = native java.util.ListResourceBundle where

  native getKeys :: Mutable s ListResourceBundle -> STMutable s (Enumeration String)

  native handleGetObject :: Mutable s ListResourceBundle -> String -> ST s Object

{--
  PropertyResourceBundle is a concrete subclass of ResourceBundle that manages resources for a locale using a set of static strings from a property file.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/PropertyResourceBundle.html JavaDoc'
-}
data PropertyResourceBundle = native java.util.PropertyResourceBundle where

  native new :: MutableIO InputStream -> IOMutable PropertyResourceBundle throws IOException
              | MutableIO Reader -> IOMutable PropertyResourceBundle throws IOException

  native getKeys :: Mutable s PropertyResourceBundle -> STMutable s (Enumeration String)

  native handleGetObject :: Mutable s PropertyResourceBundle -> String -> ST s Object

{--
  Resource bundles contain locale-specific objects.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.html JavaDoc'
-}
data ResourceBundle = native java.util.ResourceBundle where

  native clearCache java.util.ResourceBundle.clearCache :: () -> ST s ()
                                                         | MutableIO ClassLoader -> IO ()

  native containsKey :: Mutable s ResourceBundle -> String -> ST s Bool

  native getBundle java.util.ResourceBundle.getBundle :: String -> Locale -> ResourceBundle_Control -> STMutable s ResourceBundle
                                                       | String -> Locale -> MutableIO ClassLoader -> IOMutable ResourceBundle
                                                       | String -> Locale -> MutableIO ClassLoader -> ResourceBundle_Control -> IOMutable ResourceBundle
                                                       | String -> STMutable s ResourceBundle
                                                       | String -> ResourceBundle_Control -> STMutable s ResourceBundle
                                                       | String -> Locale -> STMutable s ResourceBundle

  native getKeys :: Mutable s ResourceBundle -> STMutable s (Enumeration String)

  native getLocale :: Mutable s ResourceBundle -> ST s Locale

  native getObject :: Mutable s ResourceBundle -> String -> ST s Object

  native getString :: Mutable s ResourceBundle -> String -> ST s String

  native getStringArray :: Mutable s ResourceBundle -> String -> STMutable s (JArray String)

  native keySet :: Mutable s ResourceBundle -> STMutable s (Set String)

{--
  ResourceBundle_Control defines a set of callback methods that are invoked by the
  'https://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.html
  #getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader,%20java.util.ResourceBundle.Control) ResourceBundle.getBundle'
  factory methods during the bundle loading process.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.Control.html JavaDoc'
-}
data ResourceBundle_Control = pure native java.util.ResourceBundle.Control where

  native format_default java.util.ResourceBundle.Control.FORMAT_DEFAULT :: STMutable s (List String)
  native format_class java.util.ResourceBundle.Control.FORMAT_CLASS :: STMutable s (List String)
  native format_properties java.util.ResourceBundle.Control.FORMAT_PROPERTIES :: STMutable s (List String)
  pure native ttl_dont_cache java.util.ResourceBundle.Control.TTL_DONT_CACHE :: Long
  pure native ttl_no_expiration_control java.util.ResourceBundle.Control.TTL_NO_EXPIRATION_CONTROL :: Long

  native getCandidateLocales :: ResourceBundle_Control -> String -> Locale -> STMutable s (List Locale)

  native getControl java.util.ResourceBundle.Control.getControl :: Mutable s (List String) -> ST s ResourceBundle_Control

  pure native getFallbackLocale :: ResourceBundle_Control -> String -> Locale -> Locale

  native getFormats :: ResourceBundle_Control -> String -> STMutable s (List String)

  native getNoFallbackControl java.util.ResourceBundle.Control.getNoFallbackControl :: Mutable s (List String) -> ST s ResourceBundle_Control

  pure native getTimeToLive :: ResourceBundle_Control -> String -> Locale -> Long

  native needsReload :: ResourceBundle_Control -> String -> Locale -> String -> MutableIO ClassLoader -> MutableIO ResourceBundle -> Long -> IO Bool

  native newBundle ::
    ResourceBundle_Control -> String -> Locale -> String -> MutableIO ClassLoader -> Bool -> IOMutable ResourceBundle
      throws IllegalAccessException, InstantiationException, IOException

  pure native toBundleName :: ResourceBundle_Control -> String -> Locale -> String

  pure native toResourceName :: ResourceBundle_Control -> String -> String -> String

{--
  A simple service-provider loading facility.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html JavaDoc'
-}
data ServiceLoader t = native java.util.ServiceLoader where

  native iterator :: MutableIO (ServiceLoader t) -> IOMutable (Iterator t)

  native load java.util.ServiceLoader.load{s} :: Class s -> IOMutable (ServiceLoader s)
                                            | Class s -> MutableIO ClassLoader -> IOMutable (ServiceLoader s)

  native loadInstalled java.util.ServiceLoader.loadInstalled{s} :: Class s -> IOMutable (ServiceLoader s)
 
  native reload :: MutableIO (ServiceLoader t) -> IO ()

  native toString :: MutableIO (ServiceLoader t) -> IO String

{--
  SimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/SimpleTimeZone.html JavaDoc'
-}
data SimpleTimeZone = native java.util.SimpleTimeZone where

  pure native wall_time java.util.SimpleTimeZone.WALL_TIME :: Int
  pure native standard_time java.util.SimpleTimeZone.STANDARD_TIME :: Int
  pure native utc_time java.util.SimpleTimeZone.UTC_TIME :: Int

  native new :: Int -> String -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> STMutable s SimpleTimeZone
              | Int -> String -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> STMutable s SimpleTimeZone
              | Int -> String -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> STMutable s SimpleTimeZone
              | Int -> String -> STMutable s SimpleTimeZone

  native clone :: Mutable s SimpleTimeZone -> ST s Object

  native equals :: Mutable s SimpleTimeZone -> Object -> ST s Bool

  native getDSTSavings :: Mutable s SimpleTimeZone -> ST s Int

  native getOffset :: Mutable s SimpleTimeZone -> Long -> ST s Int
                    | Mutable s SimpleTimeZone -> Int -> Int -> Int -> Int -> Int -> Int -> ST s Int

  native getRawOffset :: Mutable s SimpleTimeZone -> ST s Int

  native hasSameRules :: Mutable s SimpleTimeZone -> TimeZone -> ST s Bool

  native hashCode :: Mutable s SimpleTimeZone -> ST s Int

  native inDaylightTime :: Mutable s SimpleTimeZone -> Mutable s Date -> ST s Bool

  native observesDaylightTime :: Mutable s SimpleTimeZone -> ST s Bool

  native setDSTSavings :: Mutable s SimpleTimeZone -> Int -> ST s ()

  native setEndRule :: Mutable s SimpleTimeZone -> Int -> Int -> Int -> Int -> ST s ()
                     | Mutable s SimpleTimeZone -> Int -> Int -> Int -> ST s ()
                     | Mutable s SimpleTimeZone -> Int -> Int -> Int -> Int -> Bool -> ST s ()

  native setRawOffset :: Mutable s SimpleTimeZone -> Int -> ST s ()

  native setStartRule :: Mutable s SimpleTimeZone -> Int -> Int -> Int -> Int -> Bool -> ST s ()
                       | Mutable s SimpleTimeZone -> Int -> Int -> Int -> Int -> ST s ()
                       | Mutable s SimpleTimeZone -> Int -> Int -> Int -> ST s ()

  native setStartYear :: Mutable s SimpleTimeZone -> Int -> ST s ()

  native toString :: Mutable s SimpleTimeZone -> ST s String

  native useDaylightTime :: Mutable s SimpleTimeZone -> ST s Bool

instance Serializable SimpleTimeZone

{--
  The string tokenizer class allows an application to break a string into tokens.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html JavaDoc'
-}
data StringTokenizer = native java.util.StringTokenizer where

  native new :: String -> String -> STMutable s StringTokenizer
              | String -> String -> Bool -> STMutable s StringTokenizer
              | String -> STMutable s StringTokenizer

  native countTokens :: Mutable s StringTokenizer -> ST s Int

  native hasMoreElements :: Mutable s StringTokenizer -> ST s Bool

  native hasMoreTokens :: Mutable s StringTokenizer -> ST s Bool

  native nextElement :: Mutable s StringTokenizer -> ST s Object

  native nextToken :: Mutable s StringTokenizer -> String -> ST s String
                    | Mutable s StringTokenizer -> ST s String

{--
  A facility for threads to schedule tasks for future execution in a background thread.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/Timer.html JavaDoc'
-}
data Timer = native java.util.Timer where

  native new :: String -> Bool -> STMutable s Timer
              | Bool -> STMutable s Timer
              | () -> STMutable s Timer
              | String -> STMutable s Timer

  native cancel :: Mutable s Timer -> ST s ()

  native purge :: Mutable s Timer -> ST s Int

  native schedule :: Mutable s Timer -> Mutable s TimerTask -> Mutable s Date -> ST s ()
                   | Mutable s Timer -> Mutable s TimerTask -> Mutable s Date -> Long -> ST s ()
                   | Mutable s Timer -> Mutable s TimerTask -> Long -> ST s ()
                   | Mutable s Timer -> Mutable s TimerTask -> Long -> Long -> ST s ()

  native scheduleAtFixedRate :: Mutable s Timer -> Mutable s TimerTask -> Mutable s Date -> Long -> ST s ()
                              | Mutable s Timer -> Mutable s TimerTask -> Long -> Long -> ST s ()

{--
  A task that can be scheduled for one-time or repeated execution by a Timer.

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/TimerTask.html JavaDoc'
-}
data TimerTask = native java.util.TimerTask where

  native cancel :: Mutable s TimerTask -> ST s Bool

  native run :: Mutable s TimerTask -> ST s ()

  native scheduledExecutionTime :: Mutable s TimerTask -> ST s Long

{--
  A class that represents an immutable universally unique identifier (UUID).

  More: 'https://docs.oracle.com/javase/7/docs/api/java/util/UUID.html JavaDoc'
-}
data UUID = pure native java.util.UUID where

  native new :: Long -> Long -> ST s UUID

  pure native clockSequence :: UUID -> Int

  pure native compareTo :: UUID -> UUID -> Int

  pure native equals :: UUID -> Object -> Bool

  pure native fromString java.util.UUID.fromString :: String -> UUID

  pure native getLeastSignificantBits :: UUID -> Long

  pure native getMostSignificantBits :: UUID -> Long

  pure native hashCode :: UUID -> Int

  native nameUUIDFromBytes java.util.UUID.nameUUIDFromBytes :: Mutable s (JArray Byte) -> ST s UUID

  pure native node :: UUID -> Long

  native randomUUID java.util.UUID.randomUUID :: () -> ST s UUID

  pure native timestamp :: UUID -> Long

  pure native toString :: UUID -> String

  pure native variant :: UUID -> Int

  pure native version :: UUID -> Int

instance Serializable UUID

data InvalidPropertiesFormatException = pure native java.util.InvalidPropertiesFormatException
derive Exceptional InvalidPropertiesFormatException

data ConcurrentModificationException = pure native java.util.ConcurrentModificationException
derive Exceptional ConcurrentModificationException

data DuplicateFormatFlagsException = pure native java.util.DuplicateFormatFlagsException
derive Exceptional DuplicateFormatFlagsException

data FormatFlagsConversionMismatchException = pure native java.util.FormatFlagsConversionMismatchException
derive Exceptional FormatFlagsConversionMismatchException

data FormatterClosedException = pure native java.util.FormatterClosedException
derive Exceptional FormatterClosedException

data IllegalFormatCodePointException = pure native java.util.IllegalFormatCodePointException
derive Exceptional IllegalFormatCodePointException

data IllegalFormatConversionException = pure native java.util.IllegalFormatConversionException
derive Exceptional IllegalFormatConversionException

data IllegalFormatException = pure native java.util.IllegalFormatException
derive Exceptional IllegalFormatException

data IllegalFormatFlagsException = pure native java.util.IllegalFormatFlagsException
derive Exceptional IllegalFormatFlagsException

data IllegalFormatPrecisionException = pure native java.util.IllegalFormatPrecisionException
derive Exceptional IllegalFormatPrecisionException

data IllegalFormatWidthException = pure native java.util.IllegalFormatWidthException
derive Exceptional IllegalFormatWidthException

data IllformedLocaleException = pure native java.util.IllformedLocaleException
derive Exceptional IllformedLocaleException

data InputMismatchException = pure native java.util.InputMismatchException
derive Exceptional InputMismatchException

data MissingFormatArgumentException = pure native java.util.MissingFormatArgumentException
derive Exceptional MissingFormatArgumentException

data MissingFormatWidthException = pure native java.util.MissingFormatWidthException
derive Exceptional MissingFormatWidthException

data MissingResourceException = pure native java.util.MissingResourceException
derive Exceptional MissingResourceException

data ServiceConfigurationError = pure native java.util.ServiceConfigurationError
derive Exceptional ServiceConfigurationError

data TooManyListenersException = pure native java.util.TooManyListenersException
derive Exceptional TooManyListenersException

data UnknownFormatConversionException = pure native java.util.UnknownFormatConversionException
derive Exceptional UnknownFormatConversionException

data UnknownFormatFlagsException = pure native java.util.UnknownFormatFlagsException
derive Exceptional UnknownFormatFlagsException

-- Forward declarations

protected data ReadableByteChannel = native "java.nio.channels.ReadableByteChannel"

protected data Path = pure native "java.nio.file.Path"

protected data BigDecimal = pure native "java.math.BigDecimal"

protected data ByteBuffer = native "java.nio.ByteBuffer"

protected data LongBuffer = native "java.nio.LongBuffer"

protected data Permission = pure native java.security.Permission

protected data PermissionCollection = native java.security.PermissionCollection

-- already provided by Java.util.Regex
-- protected data MatchResult = pure native java.util.regex.MatchResult
